]> granicus.if.org Git - icu/commitdiff
ICU-8999 uprv_isASCIILetter()
authorMarkus Scherer <markus.icu@gmail.com>
Wed, 14 Dec 2011 23:43:56 +0000 (23:43 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Wed, 14 Dec 2011 23:43:56 +0000 (23:43 +0000)
X-SVN-Rev: 31117

icu4c/source/common/cstring.c
icu4c/source/common/cstring.h
icu4c/source/common/uloc.cpp
icu4c/source/common/uloc_tag.c

index a5b2c6bbccd4ca51310aaaba7335cd28165aecd6..e308709a9cd9f53e4173cf84fe77e7d75ff5d7f9 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1997-2003, International Business Machines
+*   Copyright (C) 1997-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
  * and the set of uppercase Latin letters is discontiguous as well.
  */
 
+U_CAPI UBool U_EXPORT2
+uprv_isASCIILetter(char c) {
+#if U_CHARSET_FAMILY==U_EBCDIC_FAMILY
+    return
+        ('a'<=c && c<='i') || ('j'<=c && c<='r') || ('s'<=c && c<='z') ||
+        ('A'<=c && c<='I') || ('J'<=c && c<='R') || ('S'<=c && c<='Z');
+#else
+    return ('a'<=c && c<='z') || ('A'<=c && c<='Z');
+#endif
+}
+
 U_CAPI char U_EXPORT2
 uprv_toupper(char c) {
 #if U_CHARSET_FAMILY==U_EBCDIC_FAMILY
index 811e2d82cf3c0d5b2fd9fdf8b1bcb383d25e1bae..f67394428a60b04743904245f9c42fc6707144d3 100644 (file)
 #define uprv_strstr(s, c) U_STANDARD_CPP_NAMESPACE strstr(s, c)
 #define uprv_strrchr(s, c) U_STANDARD_CPP_NAMESPACE strrchr(s, c)
 
+/**
+ * Is c an ASCII-repertoire letter a-z or A-Z?
+ * Note: The implementation is specific to whether ICU is compiled for
+ * an ASCII-based or EBCDIC-based machine. There just does not seem to be a better name for this.
+ */
+U_CAPI UBool U_EXPORT2
+uprv_isASCIILetter(char c);
+
 U_CAPI char U_EXPORT2
 uprv_toupper(char c);
 
index 0bf53bbc27a03b6281544fafb692e6c4a838d195..11a3a4f4887ea2a64a3eee671f94a3962c1dcfc1 100644 (file)
@@ -1248,8 +1248,6 @@ ulocimp_getLanguage(const char *localeID,
     return i;
 }
 
-#define ISASCIIALPHA(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
-
 U_CFUNC int32_t
 ulocimp_getScript(const char *localeID,
                   char *script, int32_t scriptCapacity,
@@ -1263,7 +1261,7 @@ ulocimp_getScript(const char *localeID,
 
     /* copy the second item as far as possible and count its length */
     while(!_isTerminator(localeID[idLen]) && !_isIDSeparator(localeID[idLen])
-            && ISASCIIALPHA(localeID[idLen])) {
+            && uprv_isASCIILetter(localeID[idLen])) {
         idLen++;
     }
 
index 6b109ca7051085138578130811437e383d0e240d..1f69754462187de8f20449c42a271c88e8527933 100644 (file)
@@ -59,7 +59,7 @@ typedef struct ULanguageTag {
 #define LOCALE_KEYWORD_SEP ';'
 #define LOCALE_KEY_TYPE_SEP '='
 
-#define ISALPHA(c) (((c)>='A' && (c)<='Z') || ((c)>='a' && (c)<='z'))
+#define ISALPHA(c) uprv_isASCIILetter(c)
 #define ISNUMERIC(c) ((c)>='0' && (c)<='9')
 
 static const char* EMPTY = "";