Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmbbtype.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS system libraries 00004 * FILE: lib/sdk/crt/mbstring/mbbtype.c 00005 * PURPOSE: Determines the type of a multibyte character 00006 * PROGRAMERS: 00007 * Copyright 1999 Ariadne 00008 * Copyright 1999 Alexandre Julliard 00009 * Copyright 2000 Jon Griffths 00010 * 00011 */ 00012 00013 #include <precomp.h> 00014 00015 #include <mbstring.h> 00016 #include <mbctype.h> 00017 00018 /* 00019 * @implemented 00020 */ 00021 int _mbbtype(unsigned char c , int type) 00022 { 00023 if ( type == 1 ) { 00024 if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) ) 00025 { 00026 return _MBC_TRAIL; 00027 } 00028 else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) || 00029 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) ) 00030 return _MBC_ILLEGAL; 00031 else 00032 return 0; 00033 } else { 00034 if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) { 00035 return _MBC_SINGLE; 00036 } 00037 else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) ) 00038 return _MBC_LEAD; 00039 else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) || 00040 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) ) 00041 return _MBC_ILLEGAL; 00042 else 00043 return 0; 00044 } 00045 return 0; 00046 } 00047 00048 /* 00049 * @implemented 00050 */ 00051 int _mbsbtype( const unsigned char *str, size_t n ) 00052 { 00053 int lead = 0; 00054 const unsigned char *end = str + n; 00055 00056 /* Lead bytes can also be trail bytes so we need to analyse the string. 00057 * Also we must return _MBC_ILLEGAL for chars past the end of the string 00058 */ 00059 while (str < end) /* Note: we skip the last byte - will check after the loop */ 00060 { 00061 if (!*str) 00062 return _MBC_ILLEGAL; 00063 lead = !lead && _ismbblead(*str); 00064 str++; 00065 } 00066 00067 if (lead) 00068 if (_ismbbtrail(*str)) 00069 return _MBC_TRAIL; 00070 else 00071 return _MBC_ILLEGAL; 00072 else 00073 if (_ismbblead(*str)) 00074 return _MBC_LEAD; 00075 else 00076 return _MBC_SINGLE; 00077 } Generated on Sun May 27 2012 04:36:29 for ReactOS by
1.7.6.1
|