From: Nick Ing-Simmons Date: Sun, 20 Oct 2002 16:20:37 +0000 (+0000) Subject: Handle case where octets are UTF-8 encoded X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7010e7fe2e8c56b69f901be3c3f0c98f71857bb;p=p5sagit%2Fp5-mst-13.2.git Handle case where octets are UTF-8 encoded p4raw-id: //depot/perlio@18040 --- diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index d40c869..57fc9a0 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -253,6 +253,17 @@ CODE: SV *dst = newSV(slen); SvPOK_only(dst); SvCUR_set(dst,0); + if (SvUTF8(src)) { + s = utf8_to_bytes(s,&slen); + if (s) { + SvCUR_set(src,slen); + SvUTF8_off(src); + e = s+slen; + } + else { + croak("Cannot decode string with wide characters"); + } + } while (s < e) { if (UTF8_IS_INVARIANT(*s) || UTF8_IS_START(*s)) { U8 skip = UTF8SKIP(s);