2 *******************************************************************************
4 * Copyright (C) 2003-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 #include <unicode/unistr.h>
11 #include <unicode/ustdio.h>
12 #include <unicode/brkiter.h>
15 U_CFUNC
int c_main(UFILE
*out
);
17 void printUnicodeString(UFILE
*out
, const UnicodeString
&s
) {
18 UnicodeString other
= s
;
19 u_fprintf(out
, "\"%S\"", other
.getTerminatedBuffer());
26 UErrorCode status
= U_ZERO_ERROR
;
27 out
= u_finit(stdout
, NULL
, NULL
);
29 fprintf(stderr
, "Could not initialize (finit()) over stdout! \n");
32 ucnv_setFromUCallBack(u_fgetConverter(out
), UCNV_FROM_U_CALLBACK_ESCAPE
,
33 NULL
, NULL
, NULL
, &status
);
34 if(U_FAILURE(status
)) {
35 u_fprintf(out
, "Warning- couldn't set the substitute callback - err %s\n", u_errorName(status
));
38 /* End Demo boilerplate */
40 u_fprintf(out
,"ICU Case Mapping Sample Program\n\n");
41 u_fprintf(out
, "C++ Case Mapping\n\n");
43 UnicodeString
string("This is a test");
44 /* lowercase = "istanbul" */
45 UChar lowercase
[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0};
46 /* uppercase = "LATIN CAPITAL I WITH DOT ABOVE STANBUL" */
47 UChar uppercase
[] = {0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4C, 0};
49 UnicodeString
upper(uppercase
);
50 UnicodeString
lower(lowercase
);
52 u_fprintf(out
, "\nstring: ");
53 printUnicodeString(out
, string
);
54 string
.toUpper(); /* string = "THIS IS A TEST" */
55 u_fprintf(out
, "\ntoUpper(): ");
56 printUnicodeString(out
, string
);
57 string
.toLower(); /* string = "this is a test" */
58 u_fprintf(out
, "\ntoLower(): ");
59 printUnicodeString(out
, string
);
61 u_fprintf(out
, "\n\nlowercase=%S, uppercase=%S\n", lowercase
, uppercase
);
65 string
.toLower(Locale("tr", "TR")); /* Turkish lower case map string =
67 u_fprintf(out
, "\nupper.toLower: ");
68 printUnicodeString(out
, string
);
71 string
.toUpper(Locale("tr", "TR")); /* Turkish upper case map string =
73 u_fprintf(out
, "\nlower.toUpper: ");
74 printUnicodeString(out
, string
);
77 u_fprintf(out
, "\nEnd C++ sample\n\n");