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) 2003-2004, International Business Machines
11 * Corporation and others. All Rights Reserved.
13 *******************************************************************************
16 #include <unicode/unistr.h>
17 #include <unicode/ustdio.h>
18 #include <unicode/brkiter.h>
23 U_CFUNC
int c_main(UFILE
*out
);
25 void printUnicodeString(UFILE
*out
, const UnicodeString
&s
) {
26 UnicodeString other
= s
;
27 u_fprintf(out
, "\"%S\"", other
.getTerminatedBuffer());
34 UErrorCode status
= U_ZERO_ERROR
;
35 out
= u_finit(stdout
, NULL
, NULL
);
37 fprintf(stderr
, "Could not initialize (finit()) over stdout! \n");
40 ucnv_setFromUCallBack(u_fgetConverter(out
), UCNV_FROM_U_CALLBACK_ESCAPE
,
41 NULL
, NULL
, NULL
, &status
);
42 if(U_FAILURE(status
)) {
43 u_fprintf(out
, "Warning- couldn't set the substitute callback - err %s\n", u_errorName(status
));
46 /* End Demo boilerplate */
48 u_fprintf(out
,"ICU Case Mapping Sample Program\n\n");
49 u_fprintf(out
, "C++ Case Mapping\n\n");
51 UnicodeString
string("This is a test");
52 /* lowercase = "istanbul" */
53 UChar lowercase
[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0};
54 /* uppercase = "LATIN CAPITAL I WITH DOT ABOVE STANBUL" */
55 UChar uppercase
[] = {0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4C, 0};
57 UnicodeString
upper(uppercase
);
58 UnicodeString
lower(lowercase
);
60 u_fprintf(out
, "\nstring: ");
61 printUnicodeString(out
, string
);
62 string
.toUpper(); /* string = "THIS IS A TEST" */
63 u_fprintf(out
, "\ntoUpper(): ");
64 printUnicodeString(out
, string
);
65 string
.toLower(); /* string = "this is a test" */
66 u_fprintf(out
, "\ntoLower(): ");
67 printUnicodeString(out
, string
);
69 u_fprintf(out
, "\n\nlowercase=%S, uppercase=%S\n", lowercase
, uppercase
);
73 string
.toLower(Locale("tr", "TR")); /* Turkish lower case map string =
75 u_fprintf(out
, "\nupper.toLower: ");
76 printUnicodeString(out
, string
);
79 string
.toUpper(Locale("tr", "TR")); /* Turkish upper case map string =
81 u_fprintf(out
, "\nlower.toUpper: ");
82 printUnicodeString(out
, string
);
85 u_fprintf(out
, "\nEnd C++ sample\n\n");