summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-10-13 09:52:42 -0600
committerKarl Williamson <public@khwilliamson.com>2012-10-14 09:03:38 -0600
commit03c769848502ede1a551c8271a32945860d0d2fb (patch)
tree663e2e0299fa7ce84a2ad35f7b911f673cd9b40f /utf8.h
parent1f327b5e67f741f6680b230ab89f99ab63fca5c4 (diff)
downloadperl-03c769848502ede1a551c8271a32945860d0d2fb.tar.gz
utf8.h: Correct some values for EBCDIC
It occurred to me that EBCDIC has different maximums for the number of bytes a character can occupy. This moves the definition in utf8.h to within an #ifndef EBCDIC, and adds the correct values to utfebcdic.h
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/utf8.h b/utf8.h
index 30537a88db..5330e2180f 100644
--- a/utf8.h
+++ b/utf8.h
@@ -209,6 +209,25 @@ Perl's extended UTF-8 means we can have start bytes up to FF.
(uv) < 0x80000000 ? 6 : 7 )
#endif
+/* How wide can a single UTF-8 encoded character become in bytes. */
+/* NOTE: Strictly speaking Perl's UTF-8 should not be called UTF-8 since UTF-8
+ * is an encoding of Unicode, and Unicode's upper limit, 0x10FFFF, can be
+ * expressed with 4 bytes. However, Perl thinks of UTF-8 as a way to encode
+ * non-negative integers in a binary format, even those above Unicode */
+#define UTF8_MAXBYTES 13
+
+/* The maximum number of UTF-8 bytes a single Unicode character can
+ * uppercase/lowercase/fold into. Unicode guarantees that the maximum
+ * expansion is 3 characters. On ASCIIish platforms, the highest Unicode
+ * character occupies 4 bytes, therefore this number would be 12, but this is
+ * smaller than the maximum width a single above-Unicode character can occupy,
+ * so use that instead */
+#if UTF8_MAXBYTES < 12
+#error UTF8_MAXBYTES must be at least 12
+#endif
+
+#define UTF8_MAXBYTES_CASE UTF8_MAXBYTES
+
#endif /* EBCDIC vs ASCII */
/* Rest of these are attributes of Unicode and perl's internals rather than the
@@ -270,23 +289,8 @@ Perl's extended UTF-8 means we can have start bytes up to FF.
#define isIDFIRST_lazy(p) isIDFIRST_lazy_if(p,1)
#define isALNUM_lazy(p) isALNUM_lazy_if(p,1)
-#define UTF8_MAXBYTES 13
-/* How wide can a single UTF-8 encoded character become in bytes.
- * NOTE: Strictly speaking Perl's UTF-8 should not be called UTF-8
- * since UTF-8 is an encoding of Unicode and given Unicode's current
- * upper limit only four bytes is possible. Perl thinks of UTF-8
- * as a way to encode non-negative integers in a binary format. */
#define UTF8_MAXLEN UTF8_MAXBYTES
-/* The maximum number of UTF-8 bytes a single Unicode character can
- * uppercase/lowercase/fold into; this number depends on the Unicode
- * version. An example of maximal expansion is the U+03B0 which
- * uppercases to U+03C5 U+0308 U+0301. The Unicode databases that
- * tell these things are UnicodeData.txt, CaseFolding.txt, and
- * SpecialCasing.txt. The value is 6 for strict Unicode characters, but it has
- * to be as big as Perl allows for a single character */
-#define UTF8_MAXBYTES_CASE UTF8_MAXBYTES
-
/* A Unicode character can fold to up to 3 characters */
#define UTF8_MAX_FOLD_CHAR_EXPAND 3