cfad47cfa3/tads3/vmuni.h

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
/* $Header$ */
2
3
/* 
4
 *   Copyright (c) 1999, 2002 Michael J. Roberts.  All Rights Reserved.
5
 *   
6
 *   Please see the accompanying license file, LICENSE.TXT, for information
7
 *   on using and copying this software.  
8
 */
9
/*
10
Name
11
  vmuni.h - T3 VM Unicode-specific functions
12
Function
13
  
14
Notes
15
  
16
Modified
17
  08/27/99 MJRoberts  - Creation
18
*/
19
20
#ifndef VMUNI_H
21
#define VMUNI_H
22
23
#include "stdlib.h"
24
25
/* ------------------------------------------------------------------------ */
26
/*
27
 *   Upper/lower case classification and conversion functions for Unicode
28
 *   character values.  These routines are implemented in a
29
 *   machine-generated source file (the source file is mechanically
30
 *   derived from the Unicode character database).
31
 */
32
int t3_is_lower(wchar_t ch);
33
int t3_is_upper(wchar_t ch);
34
wchar_t t3_to_lower(wchar_t ch);
35
wchar_t t3_to_upper(wchar_t ch);
36
37
/*
38
 *   Character types.  Types are mutually exclusive, so a character has
39
 *   exactly one type.  
40
 */
41
#define T3_CTYPE_NONE   0       /* character doesn't fit any other category */
42
#define T3_CTYPE_ALPHA  1           /* alphabetic, with no case information */
43
#define T3_CTYPE_UPPER  2                          /* upper-case alphabetic */
44
#define T3_CTYPE_LOWER  3                          /* lower-case alphabetic */
45
#define T3_CTYPE_DIGIT  4                                          /* digit */
46
#define T3_CTYPE_SPACE  5                          /* horizontal whitespace */
47
#define T3_CTYPE_PUNCT  6                                    /* punctuation */
48
49
/* get the character type */
50
unsigned char t3_get_chartype(wchar_t ch);
51
52
/* 
53
 *   character classification functions 
54
 */
55
56
/* alphabetic? */
57
inline int t3_is_alpha(wchar_t ch)
58
{
59
    unsigned char ctype;
60
61
    ctype = t3_get_chartype(ch);
62
    return (ctype == T3_CTYPE_UPPER
63
            || ctype == T3_CTYPE_LOWER
64
            || ctype == T3_CTYPE_ALPHA);
65
            
66
}
67
68
/* uppercase? */
69
inline int t3_is_upper(wchar_t ch)
70
{
71
    return (t3_get_chartype(ch) == T3_CTYPE_UPPER);
72
}
73
74
/* lowercase? */
75
inline int t3_is_lower(wchar_t ch)
76
{
77
    return (t3_get_chartype(ch) == T3_CTYPE_LOWER);
78
}
79
80
/* digit? */
81
inline int t3_is_digit(wchar_t ch)
82
{
83
    return (t3_get_chartype(ch) == T3_CTYPE_DIGIT);
84
}
85
86
/* whitespace? */
87
inline int t3_is_space(wchar_t ch)
88
{
89
    return (t3_get_chartype(ch) == T3_CTYPE_SPACE);
90
}
91
92
/* punctuation? */
93
inline int t3_is_punct(wchar_t ch)
94
{
95
    return (t3_get_chartype(ch) == T3_CTYPE_PUNCT);
96
}
97
98
#endif /* VMUNI_H */
99