]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/legacy/legacy.cpp
2 *******************************************************************************
4 * Copyright (C) 2001, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2001jul24
14 * created by: Vladimir Weinstein
17 /******************************************************************************
18 * main program demonstrating using two versions of ICU in the same project
19 ******************************************************************************/
22 #include "unicode/utypes.h"
23 #include "unicode/ustring.h"
25 void test_current(UChar data
[][5], uint32_t size
, uint32_t maxLen
, uint8_t keys
[][32]);
26 void test_legacy(UChar data
[][5], uint32_t size
, uint32_t maxlen
, uint8_t keys
[][32]);
28 void printZTUChar(const UChar
*str
) {
30 if(*str
> 0x1F && *str
< 0x80) {
31 fprintf(stdout
, "%c", (*str
) & 0xFF);
33 fprintf(stdout
, "\\u%04X", *str
);
39 void printArray(const char* const comment
, const UChar UArray
[][5], int32_t arraySize
) {
40 fprintf (stdout
, "%s\n", comment
);
42 for(i
= 0; i
<arraySize
; i
++) {
43 fprintf(stdout
, "%d ", i
);
44 printZTUChar(UArray
[i
]);
45 fprintf(stdout
, "\n");
49 void printKeys(const char *comment
, uint8_t keys
[][32], int32_t keySize
) {
51 uint8_t *currentKey
= NULL
;
52 fprintf(stdout
, "%s\n", comment
);
53 for(i
= 0; i
<keySize
; i
++) {
55 while(*currentKey
!= 0) {
56 if(*currentKey
== 1) {
57 fprintf(stdout
, "01 ");
59 fprintf(stdout
, "%02X", *currentKey
);
63 fprintf(stdout
, " 00\n");
68 //int main(int argc, const char * const argv[]) {
69 int main(int, const char * const *) {
70 static const char* test
[4] = {
71 "\\u304D\\u3085\\u3046\\u0000",
72 "\\u30AD\\u30E6\\u30A6\\u0000",
73 "\\u304D\\u3086\\u3046\\u0000",
74 "\\u30AD\\u30E5\\u30A6\\u0000"
78 static const char* test2
[4] = {
86 static UChar uTest
[4][5];
88 static uint8_t keys
[4][32];
92 for(i
= 0; i
<4; i
++) {
93 u_unescape(test
[i
], uTest
[i
], 5);
95 printArray("Before current", uTest
, 4);
96 test_current(uTest
, 4, 5, keys
);
97 printArray("After current", uTest
, 4);
98 printKeys("Current keys", keys
, 4);
100 for(i
= 0; i
<4; i
++) {
101 u_unescape(test
[i
], uTest
[i
], 5);
103 printArray("Before legacy", uTest
, 4);
104 test_legacy(uTest
, 4, 5, keys
);
105 printArray("After legacy", uTest
, 4);
106 printKeys("Legacy keys", keys
, 4);