summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-02-13 04:43:43 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-02-13 04:43:43 +0000
commit8c19e1b53a04299dd91f058f8d14822bb18b45e5 (patch)
tree01d9578f912fc02d1cb0bdb1b31665fa1f46b7ca /utf8.c
parente87322b2e8419defee882ceb696c003953500063 (diff)
downloadperl-8c19e1b53a04299dd91f058f8d14822bb18b45e5.tar.gz
Iteration continues.
p4raw-id: //depot/perl@14669
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/utf8.c b/utf8.c
index 4913b44eb5..0f84d3621a 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1325,15 +1325,23 @@ Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *norma
U8 tmpbuf[UTF8_MAXLEN_FOLD+1];
U8 *d = tmpbuf;
U8 *t, *tend;
- STRLEN tlen;
- for (t = ustrp, tend = t + len; t < tend; t += tlen) {
- UV c = utf8_to_uvchr(t, &tlen);
-
- if (tlen > 0)
- d = uvchr_to_utf8(d, UNI_TO_NATIVE(c));
- else
- break;
+ if (SvUTF8(val)) {
+ STRLEN tlen = 0;
+
+ for (t = ustrp, tend = t + len;
+ t < tend; t += tlen) {
+ UV c = utf8_to_uvchr(t, &tlen);
+
+ if (tlen > 0)
+ d = uvchr_to_utf8(d, UNI_TO_NATIVE(c));
+ else
+ break;
+ }
+ } else {
+ for (t = ustrp, tend = t + len;
+ t < tend; t++)
+ d = uvchr_to_utf8(d, UNI_TO_NATIVE(*t));
}
len = d - tmpbuf;
Copy(tmpbuf, ustrp, len, U8);
@@ -1341,15 +1349,10 @@ Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *norma
#endif
}
else {
- U8 c = UNI_TO_NATIVE(*s);
-
- if (NATIVE_IS_INVARIANT(c))
- ustrp[0] = c;
- else {
- ustrp[0] = UTF8_EIGHT_BIT_HI(c);
- ustrp[1] = UTF8_EIGHT_BIT_LO(c);
- len = 2;
- }
+ UV c = UNI_TO_NATIVE(*(U8*)s);
+ U8 *d = uvchr_to_utf8(ustrp, c);
+
+ len = d - ustrp;
}
if (lenp)
*lenp = len;