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>
21 U_CFUNC
int c_main(UFILE
*out
);
23 void printUnicodeString(UFILE
*out
, const UnicodeString
&s
) {
24 UnicodeString other
= s
;
25 u_fprintf(out
, "\"%S\"", other
.getTerminatedBuffer());
32 UErrorCode status
= U_ZERO_ERROR
;
33 out
= u_finit(stdout
, NULL
, NULL
);
35 fprintf(stderr
, "Could not initialize (finit()) over stdout! \n");
38 ucnv_setFromUCallBack(u_fgetConverter(out
), UCNV_FROM_U_CALLBACK_ESCAPE
,
39 NULL
, NULL
, NULL
, &status
);
40 if(U_FAILURE(status
)) {
41 u_fprintf(out
, "Warning- couldn't set the substitute callback - err %s\n", u_errorName(status
));
44 /* End Demo boilerplate */
46 u_fprintf(out
,"ICU Case Mapping Sample Program\n\n");
47 u_fprintf(out
, "C++ Case Mapping\n\n");
49 UnicodeString
string("This is a test");
50 /* lowercase = "istanbul" */
51 UChar lowercase
[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0};
52 /* uppercase = "LATIN CAPITAL I WITH DOT ABOVE STANBUL" */
53 UChar uppercase
[] = {0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4C, 0};
55 UnicodeString
upper(uppercase
);
56 UnicodeString
lower(lowercase
);
58 u_fprintf(out
, "\nstring: ");
59 printUnicodeString(out
, string
);
60 string
.toUpper(); /* string = "THIS IS A TEST" */
61 u_fprintf(out
, "\ntoUpper(): ");
62 printUnicodeString(out
, string
);
63 string
.toLower(); /* string = "this is a test" */
64 u_fprintf(out
, "\ntoLower(): ");
65 printUnicodeString(out
, string
);
67 u_fprintf(out
, "\n\nlowercase=%S, uppercase=%S\n", lowercase
, uppercase
);
71 string
.toLower(Locale("tr", "TR")); /* Turkish lower case map string =
73 u_fprintf(out
, "\nupper.toLower: ");
74 printUnicodeString(out
, string
);
77 string
.toUpper(Locale("tr", "TR")); /* Turkish upper case map string =
79 u_fprintf(out
, "\nlower.toUpper: ");
80 printUnicodeString(out
, string
);
83 u_fprintf(out
, "\nEnd C++ sample\n\n");