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