From: Nicholas Clark Date: Mon, 31 Oct 2005 13:22:01 +0000 (+0000) Subject: uvchr_to_utf8() and utf8n_to_uvchr() are mathoms on ASCII based X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0f830e0b62c9aecd65b9af85ec46817dc940d8af;hp=59abd33597c479b9e5620fa06c6c6a9f2917f858;p=p5sagit%2Fp5-mst-13.2.git uvchr_to_utf8() and utf8n_to_uvchr() are mathoms on ASCII based systems, and not on EBCDIC, so some more thinking is going to be needed here. p4raw-id: //depot/perl@25921 --- diff --git a/mathoms.c b/mathoms.c index 9d063e0..39ff004 100644 --- a/mathoms.c +++ b/mathoms.c @@ -406,58 +406,6 @@ Perl_sv_utf8_upgrade(pTHX_ register SV *sv) return sv_utf8_upgrade_flags(sv, SV_GMAGIC); } -/* -=for apidoc A|U8 *|uvchr_to_utf8|U8 *d|UV uv - -Adds the UTF-8 representation of the Native codepoint C to the end -of the string C; C should be have at least C free -bytes available. The return value is the pointer to the byte after the -end of the new character. In other words, - - d = uvchr_to_utf8(d, uv); - -is the recommended wide native character-aware way of saying - - *(d++) = uv; - -=cut -*/ - -/* On ASCII machines this is normally a macro but we want a - real function in case XS code wants it -*/ -#undef Perl_uvchr_to_utf8 -U8 * -Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv) -{ - return Perl_uvuni_to_utf8_flags(aTHX_ d, NATIVE_TO_UNI(uv), 0); -} - - -/* -=for apidoc A|UV|utf8n_to_uvchr|U8 *s|STRLEN curlen|STRLEN *retlen|U32 -flags - -Returns the native character value of the first character in the string -C -which is assumed to be in UTF-8 encoding; C will be set to the -length, in bytes, of that character. - -Allows length and flags to be passed to low level routine. - -=cut -*/ -/* On ASCII machines this is normally a macro but we want - a real function in case XS code wants it -*/ -#undef Perl_utf8n_to_uvchr -UV -Perl_utf8n_to_uvchr(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, -U32 flags) -{ - const UV uv = Perl_utf8n_to_uvuni(aTHX_ s, curlen, retlen, flags); - return UNI_TO_NATIVE(uv); -} int Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...) { diff --git a/utf8.c b/utf8.c index 1b8c168..e9794fc 100644 --- a/utf8.c +++ b/utf8.c @@ -1753,6 +1753,33 @@ Perl_swash_fetch(pTHX_ SV *sv, const U8 *ptr, bool do_utf8) return 0; } +/* +=for apidoc A|U8 *|uvchr_to_utf8|U8 *d|UV uv + +Adds the UTF-8 representation of the Native codepoint C to the end +of the string C; C should be have at least C free +bytes available. The return value is the pointer to the byte after the +end of the new character. In other words, + + d = uvchr_to_utf8(d, uv); + +is the recommended wide native character-aware way of saying + + *(d++) = uv; + +=cut +*/ + +/* On ASCII machines this is normally a macro but we want a + real function in case XS code wants it +*/ +#undef Perl_uvchr_to_utf8 +U8 * +Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv) +{ + return Perl_uvuni_to_utf8_flags(aTHX_ d, NATIVE_TO_UNI(uv), 0); +} + U8 * Perl_uvchr_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags) { @@ -1760,6 +1787,31 @@ Perl_uvchr_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags) } /* +=for apidoc A|UV|utf8n_to_uvchr|U8 *s|STRLEN curlen|STRLEN *retlen|U32 +flags + +Returns the native character value of the first character in the string +C +which is assumed to be in UTF-8 encoding; C will be set to the +length, in bytes, of that character. + +Allows length and flags to be passed to low level routine. + +=cut +*/ +/* On ASCII machines this is normally a macro but we want + a real function in case XS code wants it +*/ +#undef Perl_utf8n_to_uvchr +UV +Perl_utf8n_to_uvchr(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, +U32 flags) +{ + const UV uv = Perl_utf8n_to_uvuni(aTHX_ s, curlen, retlen, flags); + return UNI_TO_NATIVE(uv); +} + +/* =for apidoc A|char *|pv_uni_display|SV *dsv|U8 *spv|STRLEN len|STRLEN pvlim|UV flags Build to the scalar dsv a displayable version of the string spv,