summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@khw-desktop.(none)>2009-11-12 22:40:21 -0700
committerRafael Garcia-Suarez <rgs@consttype.org>2009-11-14 23:34:55 +0100
commit00f254e235ff10d6223aa9a402ad5b7a85689829 (patch)
treeecbf0c57e651245f5632419e0b86788eb252dac1 /handy.h
parenta1248f17ffcfa8fe0e91df962317b46b81fc0ce5 (diff)
downloadperl-00f254e235ff10d6223aa9a402ad5b7a85689829.tar.gz
add code for Unicode semantics for non-utf8 latin1 chars
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/handy.h b/handy.h
index 9ec64e0a09..848cc0e9bb 100644
--- a/handy.h
+++ b/handy.h
@@ -429,7 +429,7 @@ Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin)
alphanumeric character (including underscore) or digit.
=for apidoc Am|bool|isALPHA|char ch
-Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin)
+Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin)
alphabetic character.
=for apidoc Am|bool|isSPACE|char ch
@@ -479,7 +479,9 @@ US-ASCII (Basic Latin) range are viewed as not having any case.
# define isPUNCT(c) ispunct(c)
# define isXDIGIT(c) isxdigit(c)
# define toUPPER(c) toupper(c)
+# define toUPPER_LATIN1_MOD(c) UNI_TO_NATIVE(PL_mod_latin1_uc[(U8) NATIVE_TO_UNI(c)])
# define toLOWER(c) tolower(c)
+# define toLOWER_LATIN1(c) UNI_TO_NATIVE(PL_latin1_lc[(U8) NATIVE_TO_UNI(c)])
#else
# define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
# define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
@@ -490,6 +492,15 @@ US-ASCII (Basic Latin) range are viewed as not having any case.
# define isPRINT(c) (((c) >= 32 && (c) < 127))
# define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126))
# define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
+
+/* Use table lookup for speed */
+# define toLOWER_LATIN1(c) (PL_latin1_lc[(U8) c])
+
+/* Modified uc. Is correct uc except for three non-ascii chars which are
+ * all mapped to one of them, and these need special handling */
+# define toUPPER_LATIN1_MOD(c) (PL_mod_latin1_uc[(U8) c])
+
+/* ASCII casing. */
# define toUPPER(c) (isLOWER(c) ? (c) - ('a' - 'A') : (c))
# define toLOWER(c) (isUPPER(c) ? (c) + ('a' - 'A') : (c))
#endif