blob: 4527b3a2d245aeb171d15d107d65ce3b6583892a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/***
*mbbtype.c - Return type of byte based on previous byte (MBCS)
*
* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Return type of byte based on previous byte (MBCS)
*
*Revision History:
* 11-19-92 KRS Ported from 16-bit sources.
*
*******************************************************************************/
#ifdef _MBCS
#include <cruntime.h>
#include <mbdata.h>
#include <mbctype.h>
#include <mbstring.h>
/***
*int _mbbtype(c, ctype) - Return type of byte based on previous byte (MBCS)
*
*Purpose:
* Returns type of supplied byte. This decision is context
* sensitive so a control test condition is supplied. Normally,
* this is the type of the previous byte in the string.
*
*Entry:
* unsigned char c = character to be checked
* int ctype = control test condition (i.e., type of previous char)
*
*Exit:
* _MBC_LEAD = if 1st byte of MBCS char
* _MBC_TRAIL = if 2nd byte of MBCS char
* _MBC_SINGLE = valid single byte char
*
* _MBC_ILLEGAL = if illegal char
*
*Exceptions:
*
*******************************************************************************/
int _CRTAPI1 _mbbtype(c, ctype)
unsigned char c;
int ctype;
{
switch(ctype) {
case(_MBC_LEAD):
if (_ISTRAILBYTE(c))
return(_MBC_TRAIL);
else
return(_MBC_ILLEGAL);
case(_MBC_TRAIL):
case(_MBC_SINGLE):
case(_MBC_ILLEGAL):
if (_ISLEADBYTE(c))
return(_MBC_LEAD);
else if (_ismbbprint(c))
return(_MBC_SINGLE);
else
return(_MBC_ILLEGAL);
}
}
#endif /* _MBCS */
|