ReactOS 0.4.16-dev-300-g2aadf2e
mbbtype.c File Reference
#include <precomp.h>
#include <mbstring.h>
#include <mbctype.h>
Include dependency graph for mbbtype.c:

Go to the source code of this file.

Functions

int _mbbtype (unsigned char c, int type)
 
int _mbsbtype (const unsigned char *str, size_t n)
 

Function Documentation

◆ _mbbtype()

int _mbbtype ( unsigned char  c,
int  type 
)

Definition at line 21 of file mbbtype.c.

22{
23 if ( type == 1 ) {
24 if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) )
25 {
26 return _MBC_TRAIL;
27 }
28 else if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
29 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
30 return _MBC_ILLEGAL;
31 else
32 return 0;
33 } else {
34 if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {
35 return _MBC_SINGLE;
36 }
37 else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) )
38 return _MBC_LEAD;
39 else if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
40 ( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
41 return _MBC_ILLEGAL;
42 else
43 return 0;
44 }
45 return 0;
46}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const GLubyte * c
Definition: glext.h:8905
#define _MBC_TRAIL
Definition: msvcrt.h:825
#define _MBC_SINGLE
Definition: msvcrt.h:823
#define _MBC_LEAD
Definition: msvcrt.h:824
#define _MBC_ILLEGAL
Definition: msvcrt.h:826

◆ _mbsbtype()

int _mbsbtype ( const unsigned char str,
size_t  n 
)

Definition at line 51 of file mbbtype.c.

52{
53 int lead = 0;
54 const unsigned char *end = str + n;
55
56 /* Lead bytes can also be trail bytes so we need to analyse the string.
57 * Also we must return _MBC_ILLEGAL for chars past the end of the string
58 */
59 while (str < end) /* Note: we skip the last byte - will check after the loop */
60 {
61 if (!*str)
62 return _MBC_ILLEGAL;
63 lead = !lead && _ismbblead(*str);
64 str++;
65 }
66
67 if (lead)
68 if (_ismbbtrail(*str))
69 return _MBC_TRAIL;
70 else
71 return _MBC_ILLEGAL;
72 else
73 if (_ismbblead(*str))
74 return _MBC_LEAD;
75 else
76 return _MBC_SINGLE;
77}
GLuint GLuint end
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
_Check_return_ _CRTIMP int __cdecl _ismbbtrail(_In_ unsigned int _C)
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
const WCHAR * str