From 67ac4d39649e9ea3b8ce38feb920d6a1ed9d655e Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 6 Nov 2001 23:45:12 +0000 Subject: [PATCH] ICU-1269 make u_charFromName() work with mixed-case input names X-SVN-Rev: 6648 --- icu4c/source/common/unames.c | 17 +++++++++++++++++ icu4c/source/test/cintltst/cucdtst.c | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/icu4c/source/common/unames.c b/icu4c/source/common/unames.c index 107bb24c7b4..dde87b88bf5 100644 --- a/icu4c/source/common/unames.c +++ b/icu4c/source/common/unames.c @@ -187,11 +187,13 @@ U_CAPI UChar32 U_EXPORT2 u_charFromName(UCharNameChoice nameChoice, const char *name, UErrorCode *pErrorCode) { + char upper[120]; FindName findName; AlgorithmicRange *algRange; uint32_t *p; uint32_t i; UChar32 c; + char c0; if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { return 0xffff; @@ -206,6 +208,21 @@ u_charFromName(UCharNameChoice nameChoice, return 0xffff; } + /* uppercase the name first */ + for(i=0; ialgNamesOffset); i=*p; diff --git a/icu4c/source/test/cintltst/cucdtst.c b/icu4c/source/test/cintltst/cucdtst.c index 743e0d9993a..8b57a9f6f9c 100644 --- a/icu4c/source/test/cintltst/cucdtst.c +++ b/icu4c/source/test/cintltst/cucdtst.c @@ -1432,6 +1432,11 @@ TestCharNames() { log_err("u_enumCharNames(0..0x1100000) error %s names count=%ld\n", u_errorName(errorCode), length); } + /* test that u_charFromName() uppercases the input name, i.e., works with mixed-case names (new in 2.0) */ + if(0x61!=u_charFromName(U_UNICODE_CHAR_NAME, "LATin smALl letTER A", &errorCode)) { + log_err("u_charFromName(U_UNICODE_CHAR_NAME, \"LATin smALl letTER A\") did not find U+0061 (%s)\n", u_errorName(errorCode)); + } + /* ### TODO: test error cases and other interesting things */ }