summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorSADAHIRO Tomoyuki <BQW10602@nifty.com>2006-05-16 07:39:58 +0900
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-05-16 16:14:46 +0000
commit48fa462660ce4db8227511df5abb5557bba6f39e (patch)
tree38adfe0b3b17ac68efb387f66af3073724b34524 /pp_pack.c
parent0ce71af7a9fc04f228d597a47acc6b50ded81784 (diff)
downloadperl-48fa462660ce4db8227511df5abb5557bba6f39e.tar.gz
Re: [PATCH] upgrade bytes_to_uni
Message-Id: <20060515223901.F3B0.BQW10602@nifty.com> p4raw-id: //depot/perl@28209
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/pp_pack.c b/pp_pack.c
index 3fa0e74af0..d090c7dc77 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -707,20 +707,12 @@ S_bytes_to_uni(pTHX_ const U8 *start, STRLEN len, char *dest) {
const U8 * const end = start + len;
while (start < end) {
- U8 buffer[UTF8_MAXLEN];
- const int length =
- uvuni_to_utf8_flags(buffer, NATIVE_TO_UNI(*start), 0) - buffer;
- switch(length) {
- case 1:
- *dest++ = buffer[0];
- break;
- case 2:
- *dest++ = buffer[0];
- *dest++ = buffer[1];
- break;
- default:
- Perl_croak(aTHX_ "Perl bug: value %d UTF-8 expands to %d bytes",
- *start, length);
+ const UV uv = NATIVE_TO_ASCII(*start);
+ if (UNI_IS_INVARIANT(uv))
+ *dest++ = (char)(U8)UTF_TO_NATIVE(uv);
+ else {
+ *dest++ = (char)(U8)UTF8_EIGHT_BIT_HI(uv);
+ *dest++ = (char)(U8)UTF8_EIGHT_BIT_LO(uv);
}
start++;
}