]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/legacy/legacy.cpp
2 *******************************************************************************
4 * © 2016 and later: Unicode, Inc. and others.
5 * License & terms of use: http://www.unicode.org/copyright.html#License
7 *******************************************************************************
8 *******************************************************************************
10 * Copyright (C) 2001 - 2005, International Business Machines
11 * Corporation and others. All Rights Reserved.
13 *******************************************************************************
16 * tab size: 8 (not used)
19 * created on: 2001jul24
20 * created by: Vladimir Weinstein
23 /******************************************************************************
24 * main program demonstrating using two versions of ICU in the same project
25 ******************************************************************************/
28 #include "unicode/utypes.h"
29 #include "unicode/ustring.h"
31 extern "C" void test_current(UChar data
[][5], uint32_t size
, uint32_t maxLen
, uint8_t keys
[][32]);
32 extern "C" void test_legacy(UChar data
[][5], uint32_t size
, uint32_t maxlen
, uint8_t keys
[][32]);
34 void printZTUChar(const UChar
*str
) {
36 if(*str
> 0x1F && *str
< 0x80) {
37 fprintf(stdout
, "%c", (*str
) & 0xFF);
39 fprintf(stdout
, "\\u%04X", *str
);
45 void printArray(const char* const comment
, const UChar UArray
[][5], int32_t arraySize
) {
46 fprintf (stdout
, "%s\n", comment
);
48 for(i
= 0; i
<arraySize
; i
++) {
49 fprintf(stdout
, "%d ", i
);
50 printZTUChar(UArray
[i
]);
51 fprintf(stdout
, "\n");
55 void printKeys(const char *comment
, uint8_t keys
[][32], int32_t keySize
) {
57 uint8_t *currentKey
= NULL
;
58 fprintf(stdout
, "%s\n", comment
);
59 for(i
= 0; i
<keySize
; i
++) {
61 while(*currentKey
!= 0) {
62 if(*currentKey
== 1) {
63 fprintf(stdout
, "01 ");
65 fprintf(stdout
, "%02X", *currentKey
);
69 fprintf(stdout
, " 00\n");
74 //int main(int argc, const char * const argv[]) {
75 int main(int, const char * const *) {
76 static const char* test
[4] = {
77 "\\u304D\\u3085\\u3046\\u0000",
78 "\\u30AD\\u30E6\\u30A6\\u0000",
79 "\\u304D\\u3086\\u3046\\u0000",
80 "\\u30AD\\u30E5\\u30A6\\u0000"
84 static const char* test2
[4] = {
92 static UChar uTest
[4][5];
94 static uint8_t keys
[4][32];
98 for(i
= 0; i
<4; i
++) {
99 u_unescape(test
[i
], uTest
[i
], 5);
101 printArray("Before current", uTest
, 4);
102 test_current(uTest
, 4, 5, keys
);
103 printArray("After current", uTest
, 4);
104 printKeys("Current keys", keys
, 4);
106 for(i
= 0; i
<4; i
++) {
107 u_unescape(test
[i
], uTest
[i
], 5);
109 printArray("Before legacy", uTest
, 4);
110 test_legacy(uTest
, 4, 5, keys
);
111 printArray("After legacy", uTest
, 4);
112 printKeys("Legacy keys", keys
, 4);