From 1d68d6cd5ca16f48de9798b0758052a6de564551 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Sat, 14 Oct 2000 21:52:13 +0100 Subject: 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 --- utf8.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'utf8.h') 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 -- cgit v1.2.1