diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-06-14 09:05:07 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-06-14 09:05:07 +0000 |
commit | 8800c35a0a1b4f206c0a9ba7f62bf82cc177d98e (patch) | |
tree | 0807339b981ee6d680f532b722b26721ce3fb6d5 /universal.c | |
parent | 974da8e5aded27d81bcf7d5c0c5998c377065269 (diff) | |
download | perl-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.c | 20 |
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; |