]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/props/props.cpp
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) 2000, International Business Machines
11 * Corporation and others. All Rights Reserved.
13 *******************************************************************************
14 * file name: props.cpp
16 * tab size: 8 (not used)
19 * created on: 2000sep22
20 * created by: Markus W. Scherer
22 * This file contains sample code that illustrates the use of the ICU APIs
23 * for Unicode character properties.
26 #define __STDC_FORMAT_MACROS 1
30 #include "unicode/utypes.h"
31 #include "unicode/uchar.h"
32 #include "unicode/uclean.h"
35 printProps(UChar32 codePoint
) {
39 /* get the character name */
40 errorCode
=U_ZERO_ERROR
;
41 u_charName(codePoint
, U_UNICODE_CHAR_NAME
, buffer
, sizeof(buffer
), &errorCode
);
43 /* print the code point and the character name */
44 printf("U+%04" PRId32
"\t%s\n", codePoint
, buffer
);
46 /* print some properties */
47 printf(" general category (numeric enum value): %u\n", u_charType(codePoint
));
49 /* note: these APIs do not provide the data from SpecialCasing.txt */
50 printf(" is lowercase: %d uppercase: U+%04" PRId32
"\n", u_islower(codePoint
), u_toupper(codePoint
));
52 printf(" is digit: %d decimal digit value: %d\n", u_isdigit(codePoint
), u_charDigitValue(codePoint
));
54 printf(" BiDi directional category (numeric enum value): %u\n", u_charDirection(codePoint
));
57 /* Note: In ICU 2.0, the Unicode class is deprecated - it is a pure wrapper around the C APIs above. */
60 main(int argc
, const char *argv
[]) {
63 0xd, 0x20, 0x2d, 0x35, 0x65, 0x284, 0x665, 0x5678, 0x23456, 0x10317, 0x1D01F, 0x10fffd
67 for(i
=0; i
<sizeof(codePoints
)/sizeof(codePoints
[0]); ++i
) {
68 printProps(codePoints
[i
]);