summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-11-24 14:58:47 -0700
committerKarl Williamson <khw@cpan.org>2014-11-24 15:11:52 -0700
commit3ece276e6c082406cbccdc9ccbbd3a6fb3f91bf6 (patch)
treec72b3f4642b5e5bfd694aac820d14ac9420a67b6 /pp_pack.c
parent99f862a1794060158d563eeb2ff6fe74e048b394 (diff)
downloadperl-3ece276e6c082406cbccdc9ccbbd3a6fb3f91bf6.tar.gz
pp_pack.c: Make pack('U', 0x41) eq 'A'
The 'U' pack/unpack format must be in terms of Unicode code points.
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pp_pack.c b/pp_pack.c
index fa1b113829..eb63db96e8 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1318,10 +1318,16 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
len = UTF8SKIP(result);
if (!uni_to_bytes(aTHX_ &ptr, strend,
(char *) &result[1], len-1, 'U')) break;
- auv = utf8n_to_uvchr(result, len, &retlen, UTF8_ALLOW_DEFAULT);
+ auv = NATIVE_TO_UNI(utf8n_to_uvchr(result,
+ len,
+ &retlen,
+ UTF8_ALLOW_DEFAULT));
s = ptr;
} else {
- auv = utf8n_to_uvchr((U8*)s, strend - s, &retlen, UTF8_ALLOW_DEFAULT);
+ auv = NATIVE_TO_UNI(utf8n_to_uvchr((U8*)s,
+ strend - s,
+ &retlen,
+ UTF8_ALLOW_DEFAULT));
if (retlen == (STRLEN) -1 || retlen == 0)
Perl_croak(aTHX_ "Malformed UTF-8 string in unpack");
s += retlen;
@@ -2666,7 +2672,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
auv = SvUV_no_inf(fromstr, datumtype);
if (utf8) {
U8 buffer[UTF8_MAXLEN], *endb;
- endb = uvchr_to_utf8_flags(buffer, auv,
+ endb = uvchr_to_utf8_flags(buffer, UNI_TO_NATIVE(auv),
warn_utf8 ?
0 : UNICODE_ALLOW_ANY);
if (cur+(endb-buffer)*UTF8_EXPAND >= end) {
@@ -2684,7 +2690,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
GROWING(0, cat, start, cur, len+UTF8_MAXLEN);
end = start+SvLEN(cat)-UTF8_MAXLEN;
}
- cur = (char *) uvchr_to_utf8_flags((U8 *) cur, auv,
+ cur = (char *) uvchr_to_utf8_flags((U8 *) cur, UNI_TO_NATIVE(auv),
warn_utf8 ?
0 : UNICODE_ALLOW_ANY);
}