1 /*---------------------------------------------------------------------------*
2 Project: Revolution ENC sample demo
3 File: latin.c
4
5 Copyright 2006 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Log: latin.c,v $
14 Revision 1.2 2006/10/31 08:56:32 yoshioka_yasuhiro
15 Modified the table of ISO-8859-1.
16
17 Revision 1.1 2006/10/27 12:20:37 yoshioka_yasuhiro
18 Initial commit.
19
20 $NoKeywords: $
21 *---------------------------------------------------------------------------*/
22
23 #include <revolution.h>
24 #include <revolution/enc.h>
25
26 #include "validate.h"
27 #include "demostrings.h"
28
main()29 int main()
30 {
31 BOOL test_clear = TRUE;
32
33 OSReport("\n* LATIN1 str -> UNICODE str *\n");
34 test_clear = test_clear && ValidateFuncToUnicode(ENCConvertStringLatin1ToUnicode, uni1_win, latin, 8);
35
36 OSReport("\n* UNICODE str -> LATIN1 str *\n");
37 test_clear = test_clear && ValidateFuncFromUnicode(ENCConvertStringUnicodeToLatin1, latin, uni1_iso, 8);
38
39 OSReport("\n* LATIN2 str -> UNICODE str *\n");
40 test_clear = test_clear && ValidateFuncToUnicode(ENCConvertStringLatin2ToUnicode, uni2, latin, 8);
41
42 OSReport("\n* UNICODE str -> LATIN2 str *\n");
43 test_clear = test_clear && ValidateFuncFromUnicode(ENCConvertStringUnicodeToLatin2, latin, uni2, 8);
44
45 OSReport("\n* LATIN3 str -> UNICODE str *\n");
46 test_clear = test_clear && ValidateFuncToUnicode(ENCConvertStringLatin3ToUnicode, uni3, latin, 8);
47
48 OSReport("\n* UNICODE str -> LATIN3 str *\n");
49 test_clear = test_clear && ValidateFuncFromUnicode(ENCConvertStringUnicodeToLatin3, latin, uni3, 8);
50
51 OSReport("\n* GREEK str -> UNICODE str *\n");
52 test_clear = test_clear && ValidateFuncToUnicode(ENCConvertStringGreekToUnicode, unigreek, latin, 8);
53
54 OSReport("\n* UNICODE str -> GREEK str *\n");
55 test_clear = test_clear && ValidateFuncFromUnicode(ENCConvertStringUnicodeToGreek, latin, unigreek, 8);
56
57 OSReport("\n* LATIN6 str -> UNICODE str *\n");
58 test_clear = test_clear && ValidateFuncToUnicode(ENCConvertStringLatin6ToUnicode, uni6, latin, 8);
59
60 OSReport("\n* UNICODE str -> LATIN6 str *\n");
61 test_clear = test_clear && ValidateFuncFromUnicode(ENCConvertStringUnicodeToLatin6, latin, uni6, 8);
62
63 OSReport("\n* LATIN9 str -> UNICODE str *\n");
64 test_clear = test_clear && ValidateFuncToUnicode(ENCConvertStringLatin9ToUnicode, uni9, latin, 8);
65
66 OSReport("\n* UNICODE str -> LATIN9 str *\n");
67 test_clear = test_clear && ValidateFuncFromUnicode(ENCConvertStringUnicodeToLatin9, latin, uni9, 8);
68
69 /* character */
70 {
71 u8 char8;
72 u16 char16;
73 u8 lc;
74 u16 wc;
75 s32 srclen, dstlen;
76 s32 err_code;
77
78 /* LATIN1 char -> UNICODE char */
79 OSReport("\n* LATIN1 char -> UNICODE char *\n");
80 lc = 0x80;
81 wc = 0x20AC;
82 srclen = 1;
83 dstlen = 1;
84 err_code = ENCConvertStringLatin1ToUnicode(&char16, &dstlen, &lc, &srclen);
85 if (char16 == wc)
86 {
87 OSReport("SUCCESS\n");
88 }
89 else
90 {
91 OSReport("FAILURE\n");
92 test_clear = FALSE;
93 }
94 OSReport("%#x -> %#x\n", lc, wc);
95
96 /* UNICODE char -> LATIN1 char */
97 OSReport("\n* UNICODE char -> LATIN1 char *\n");
98 lc = 0xA9;
99 wc = 0x00A9;
100 srclen = 1;
101 dstlen = 1;
102 err_code = ENCConvertStringUnicodeToLatin1(&char8, &dstlen, &wc, &srclen);
103 if (char8 == lc)
104 {
105 OSReport("SUCCESS\n");
106 }
107 else
108 {
109 OSReport("FAILURE\n");
110 test_clear = FALSE;
111 }
112 OSReport("%#x -> %#x\n", wc, char8);
113 }
114
115 if (test_clear)
116 OSReport("\nTOTAL SUCCESS\n");
117 else
118 OSReport("\nTOTAL FAILURE\n");
119
120 return 0;
121 }
122