Make surrogates illegal also on EBCDIC.
Jarkko Hietaniemi [Sun, 16 Dec 2001 15:34:52 +0000 (15:34 +0000)]
p4raw-id: //depot/perl@13721

utf8.c

diff --git a/utf8.c b/utf8.c
index f21b13c..517b2e3 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -50,6 +50,8 @@ Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
        *d++ = UTF_TO_NATIVE(uv);
        return d;
     }
+    if (UNICODE_IS_SURROGATE(uv))
+        Perl_croak(aTHX_ "UTF-16 surrogate 0x%04"UVxf, uv);
 #if defined(EBCDIC)
     else {
        STRLEN len  = UNISKIP(uv);
@@ -68,8 +70,6 @@ Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
        return d;
     }
     if (uv < 0x10000) {
-        if (UNICODE_IS_SURROGATE(uv))
-           Perl_croak(aTHX_ "UTF-16 surrogate 0x%04"UVxf, uv);
        *d++ = (( uv >> 12)         | 0xe0);
        *d++ = (((uv >>  6) & 0x3f) | 0x80);
        *d++ = (( uv        & 0x3f) | 0x80);