Fix valid_utf8_to_uvchr() for EBCDIC
authorKarl Williamson <public@khwilliamson.com>
Mon, 18 Mar 2013 17:43:42 +0000 (11:43 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 29 Aug 2013 15:56:03 +0000 (09:56 -0600)
utf8.c

diff --git a/utf8.c b/utf8.c
index e9b0f5c..fb3934c 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -936,7 +936,7 @@ Perl_valid_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
 {
     UV expectlen = UTF8SKIP(s);
     const U8* send = s + expectlen;
-    UV uv = NATIVE_UTF8_TO_I8(*s);
+    UV uv = *s;
 
     PERL_ARGS_ASSERT_VALID_UTF8_TO_UVCHR;
 
@@ -946,9 +946,13 @@ Perl_valid_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
 
     /* An invariant is trivially returned */
     if (expectlen == 1) {
-        return LATIN1_TO_NATIVE(uv);
+       return uv;
     }
 
+#ifdef EBCDIC
+    uv = NATIVE_UTF8_TO_I8(uv);
+#endif
+
     /* Remove the leading bits that indicate the number of bytes, leaving just
      * the bits that are part of the value */
     uv &= UTF_START_MASK(expectlen);