summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-14 09:05:07 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-14 09:05:07 +0000
commit8800c35a0a1b4f206c0a9ba7f62bf82cc177d98e (patch)
tree0807339b981ee6d680f532b722b26721ce3fb6d5 /universal.c
parent974da8e5aded27d81bcf7d5c0c5998c377065269 (diff)
downloadperl-8800c35a0a1b4f206c0a9ba7f62bf82cc177d98e.tar.gz
Having to pull in the whole Encode just to get SvUTF8()
is a bit too much: introduce utf8::is_utf8(). p4raw-id: //depot/perl@19777
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/universal.c b/universal.c
index e7889fb1fd..0fe94d2225 100644
--- a/universal.c
+++ b/universal.c
@@ -171,6 +171,7 @@ XS(XS_version_numify);
XS(XS_version_vcmp);
XS(XS_version_boolean);
XS(XS_version_noop);
+XS(XS_utf8_is_utf8);
XS(XS_utf8_valid);
XS(XS_utf8_encode);
XS(XS_utf8_decode);
@@ -210,6 +211,7 @@ Perl_boot_core_UNIVERSAL(pTHX)
newXS("version::(nomethod", XS_version_noop, file);
newXS("version::noop", XS_version_noop, file);
}
+ newXS("utf8::is_utf8", XS_utf8_is_utf8, file);
newXS("utf8::valid", XS_utf8_valid, file);
newXS("utf8::encode", XS_utf8_encode, file);
newXS("utf8::decode", XS_utf8_decode, file);
@@ -526,6 +528,24 @@ XS(XS_version_noop)
XSRETURN_EMPTY;
}
+XS(XS_utf8_is_utf8)
+{
+ dXSARGS;
+ if (items != 1)
+ Perl_croak(aTHX_ "Usage: utf8::is_utf8(sv)");
+ {
+ SV * sv = ST(0);
+ {
+ STRLEN len;
+ if (SvUTF8(sv))
+ XSRETURN_YES;
+ else
+ XSRETURN_NO;
+ }
+ }
+ XSRETURN_EMPTY;
+}
+
XS(XS_utf8_valid)
{
dXSARGS;