summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1999-07-06 21:47:04 +0000
committerJarkko Hietaniemi <jhi@iki.fi>1999-07-06 21:47:04 +0000
commitb8c5462f6edbb2dd616e1733df011beee816eee1 (patch)
tree8769adc1886492ed5c33f80684e9905c3f407ee4 /utf8.c
parent27806c827bf94df47a488c71aa19376daf71342b (diff)
downloadperl-b8c5462f6edbb2dd616e1733df011beee816eee1.tar.gz
POSIX [[:character class:]] support for standard, locale,
and utf8. If both utf8 and locale are on, utf8 wins. I don't fully understand why so many tables changed in lib/unicode because of "make" -- maybe it was just overdue. p4raw-id: //depot/cfgperl@3624
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c112
1 files changed, 111 insertions, 1 deletions
diff --git a/utf8.c b/utf8.c
index 8c7aee2d89..0e52f211f6 100644
--- a/utf8.c
+++ b/utf8.c
@@ -255,6 +255,14 @@ Perl_is_uni_alnum(pTHX_ U32 c)
}
bool
+Perl_is_uni_alnumc(pTHX_ U32 c)
+{
+ U8 tmpbuf[10];
+ uv_to_utf8(tmpbuf, (UV)c);
+ return is_utf8_alnumc(tmpbuf);
+}
+
+bool
Perl_is_uni_idfirst(pTHX_ U32 c)
{
U8 tmpbuf[10];
@@ -303,6 +311,22 @@ Perl_is_uni_lower(pTHX_ U32 c)
}
bool
+Perl_is_uni_cntrl(pTHX_ U32 c)
+{
+ U8 tmpbuf[10];
+ uv_to_utf8(tmpbuf, (UV)c);
+ return is_utf8_cntrl(tmpbuf);
+}
+
+bool
+Perl_is_uni_graph(pTHX_ U32 c)
+{
+ U8 tmpbuf[10];
+ uv_to_utf8(tmpbuf, (UV)c);
+ return is_utf8_graph(tmpbuf);
+}
+
+bool
Perl_is_uni_print(pTHX_ U32 c)
{
U8 tmpbuf[10];
@@ -310,6 +334,14 @@ Perl_is_uni_print(pTHX_ U32 c)
return is_utf8_print(tmpbuf);
}
+bool
+is_uni_punct(U32 c)
+{
+ U8 tmpbuf[10];
+ uv_to_utf8(tmpbuf, (UV)c);
+ return is_utf8_punct(tmpbuf);
+}
+
U32
Perl_to_uni_upper(pTHX_ U32 c)
{
@@ -343,6 +375,12 @@ Perl_is_uni_alnum_lc(pTHX_ U32 c)
}
bool
+Perl_is_uni_alnumc_lc(pTHX_ U32 c)
+{
+ return is_uni_alnumc(c); /* XXX no locale support yet */
+}
+
+bool
Perl_is_uni_idfirst_lc(pTHX_ U32 c)
{
return is_uni_idfirst(c); /* XXX no locale support yet */
@@ -379,11 +417,29 @@ Perl_is_uni_lower_lc(pTHX_ U32 c)
}
bool
+Perl_is_uni_cntrl_lc(pTHX_ U32 c)
+{
+ return is_uni_cntrl(c); /* XXX no locale support yet */
+}
+
+bool
+Perl_is_uni_graph_lc(pTHX_ U32 c)
+{
+ return is_uni_graph(c); /* XXX no locale support yet */
+}
+
+bool
Perl_is_uni_print_lc(pTHX_ U32 c)
{
return is_uni_print(c); /* XXX no locale support yet */
}
+bool
+Perl_is_uni_punct_lc(pTHX_ U32 c)
+{
+ return is_uni_punct(c); /* XXX no locale support yet */
+}
+
U32
Perl_to_uni_upper_lc(pTHX_ U32 c)
{
@@ -402,7 +458,6 @@ Perl_to_uni_lower_lc(pTHX_ U32 c)
return to_uni_lower(c); /* XXX no locale support yet */
}
-
bool
Perl_is_utf8_alnum(pTHX_ U8 *p)
{
@@ -419,6 +474,21 @@ Perl_is_utf8_alnum(pTHX_ U8 *p)
}
bool
+Perl_is_utf8_alnumc(pTHX_ U8 *p)
+{
+ if (!PL_utf8_alnum)
+ PL_utf8_alnum = swash_init("utf8", "IsAlnumC", &PL_sv_undef, 0, 0);
+ return swash_fetch(PL_utf8_alnum, p);
+/* return is_utf8_alpha(p) || is_utf8_digit(p); */
+#ifdef SURPRISINGLY_SLOWER /* probably because alpha is usually true */
+ if (!PL_utf8_alnum)
+ PL_utf8_alnum = swash_init("utf8", "",
+ sv_2mortal(newSVpv("+utf8::IsAlpha\n+utf8::IsDigit\n005F\n",0)), 0, 0);
+ return swash_fetch(PL_utf8_alnum, p);
+#endif
+}
+
+bool
Perl_is_utf8_idfirst(pTHX_ U8 *p)
{
return *p == '_' || is_utf8_alpha(p);
@@ -433,6 +503,14 @@ Perl_is_utf8_alpha(pTHX_ U8 *p)
}
bool
+Perl_is_utf8_ascii(pTHX_ U8 *p)
+{
+ if (!PL_utf8_ascii)
+ PL_utf8_ascii = swash_init("utf8", "IsAscii", &PL_sv_undef, 0, 0);
+ return swash_fetch(PL_utf8_ascii, p);
+}
+
+bool
Perl_is_utf8_space(pTHX_ U8 *p)
{
if (!PL_utf8_space)
@@ -465,6 +543,22 @@ Perl_is_utf8_lower(pTHX_ U8 *p)
}
bool
+Perl_is_utf8_cntrl(pTHX_ U8 *p)
+{
+ if (!PL_utf8_cntrl)
+ PL_utf8_cntrl = swash_init("utf8", "IsCntrl", &PL_sv_undef, 0, 0);
+ return swash_fetch(PL_utf8_cntrl, p);
+}
+
+bool
+Perl_is_utf8_graph(pTHX_ U8 *p)
+{
+ if (!PL_utf8_graph)
+ PL_utf8_graph = swash_init("utf8", "IsGraph", &PL_sv_undef, 0, 0);
+ return swash_fetch(PL_utf8_graph, p);
+}
+
+bool
Perl_is_utf8_print(pTHX_ U8 *p)
{
if (!PL_utf8_print)
@@ -473,6 +567,22 @@ Perl_is_utf8_print(pTHX_ U8 *p)
}
bool
+Perl_is_utf8_punct(pTHX_ U8 *p)
+{
+ if (!PL_utf8_punct)
+ PL_utf8_punct = swash_init("utf8", "IsPunct", &PL_sv_undef, 0, 0);
+ return swash_fetch(PL_utf8_punct, p);
+}
+
+bool
+Perl_is_utf8_xdigit(pTHX_ U8 *p)
+{
+ if (!PL_utf8_xdigit)
+ PL_utf8_xdigit = swash_init("utf8", "IsXDigit", &PL_sv_undef, 0, 0);
+ return swash_fetch(PL_utf8_xdigit, p);
+}
+
+bool
Perl_is_utf8_mark(pTHX_ U8 *p)
{
if (!PL_utf8_mark)