1// Copyright 2007 Google Inc. All Rights Reserved.
2
3#include "ascii_ctype.h"
4
5// # Table generated by this Python code (bit 0x02 is currently unused):
6// def Hex2(n):
7// return '0x' + hex(n/16)[2:] + hex(n%16)[2:]
8// def IsPunct(ch):
9// return (ord(ch) >= 32 and ord(ch) < 127 and
10// not ch.isspace() and not ch.isalnum())
11// def IsBlank(ch):
12// return ch in ' \t'
13// def IsCntrl(ch):
14// return ord(ch) < 32 or ord(ch) == 127
15// def IsXDigit(ch):
16// return ch.isdigit() or ch.lower() in 'abcdef'
17// for i in range(128):
18// ch = chr(i)
19// mask = ((ch.isalpha() and 0x01 or 0) |
20// (ch.isalnum() and 0x04 or 0) |
21// (ch.isspace() and 0x08 or 0) |
22// (IsPunct(ch) and 0x10 or 0) |
23// (IsBlank(ch) and 0x20 or 0) |
24// (IsCntrl(ch) and 0x40 or 0) |
25// (IsXDigit(ch) and 0x80 or 0))
26// print Hex2(mask) + ',',
27// if i % 16 == 7:
28// print ' //', Hex2(i & 0x78)
29// elif i % 16 == 15:
30// print
31const uint8 kAsciiPropertyBits[256] = {
32 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x00
33 0x40, 0x68, 0x48, 0x48, 0x48, 0x48, 0x40, 0x40,
34 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x10
35 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
36 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 0x20
37 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
38 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, // 0x30
39 0x84, 0x84, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
40 0x10, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x05, // 0x40
41 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
42 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, // 0x50
43 0x05, 0x05, 0x05, 0x10, 0x10, 0x10, 0x10, 0x10,
44 0x10, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x05, // 0x60
45 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
46 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, // 0x70
47 0x05, 0x05, 0x05, 0x10, 0x10, 0x10, 0x10, 0x40,
48};
49
50const uint8 kAsciiToLower[256] = {
51 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
52 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
53 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
54 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
55 64, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
56 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 91, 92, 93, 94, 95,
57 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
58 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
59 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
60 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
61 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
62 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
63 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
64 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
65 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
66 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
67};
68
69const uint8 kAsciiToUpper[256] = {
70 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
71 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
72 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
73 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
74 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
75 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
76 96, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
77 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
78 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
79 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
80 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
81 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
82 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
83 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
84 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
85 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
86};
87