summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorSimon Cozens <simon@netthink.co.uk>2000-10-14 21:52:13 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2000-10-15 16:24:44 +0000
commit1d68d6cd5ca16f48de9798b0758052a6de564551 (patch)
treecec6cf88c7c24c5ae0d5f41e34d4cc88133d4df8 /utf8.h
parent93f04dac2ed878fbeae5ba64df628ed3ab0b6e21 (diff)
downloadperl-1d68d6cd5ca16f48de9798b0758052a6de564551.tar.gz
Make ~(chr(a).chr(b)) eq chr(~a).chr(~b) on utf8.
Subject: [PATCH] Re: [ID 20000918.005] ~ on wide chars Message-ID: <20001014205213.A9645@pembro4.pmb.ox.ac.uk> p4raw-id: //depot/perl@7235
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/utf8.h b/utf8.h
index 32173ea594..7407335806 100644
--- a/utf8.h
+++ b/utf8.h
@@ -35,6 +35,24 @@ END_EXTERN_C
#define UTF8SKIP(s) PL_utf8skip[*(U8*)s]
+#ifdef HAS_QUAD
+#define UTF8LEN(uv) ( (uv) < 0x80 ? 1 : \
+ (uv) < 0x800 ? 2 : \
+ (uv) < 0x10000 ? 3 : \
+ (uv) < 0x200000 ? 4 : \
+ (uv) < 0x4000000 ? 5 : \
+ (uv) < 0x80000000 ? 6 : \
+ (uv) < 0x1000000000LL ? 7 : 13 )
+#else
+/* No, I'm not even going to *TRY* putting #ifdef inside a #define */
+#define UTF8LEN(uv) ( (uv) < 0x80 ? 1 : \
+ (uv) < 0x800 ? 2 : \
+ (uv) < 0x10000 ? 3 : \
+ (uv) < 0x200000 ? 4 : \
+ (uv) < 0x4000000 ? 5 : \
+ (uv) < 0x80000000 ? 6 : 7 )
+#endif
+
/*
* Note: we try to be careful never to call the isXXX_utf8() functions
* unless we're pretty sure we've seen the beginning of a UTF-8 character