Skip to content

Commit e3d93fd

Browse files
committed
utf8_to_utf16: Use new c9strict_utf8_to_uv()
This new function encapsulates in one call the several lines of code replaced here.
1 parent 1cd3710 commit e3d93fd

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

utf8.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,15 +3490,8 @@ Perl_utf8_to_utf16_base(pTHX_ U8* s, U8* d, Size_t bytelen, Size_t *newlen,
34903490

34913491
while (s < send) {
34923492
STRLEN retlen;
3493-
UV uv = utf8n_to_uvchr(s, send - s, &retlen,
3494-
/* No surrogates nor above-Unicode */
3495-
UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE);
3496-
3497-
/* The modern method is to keep going with malformed input,
3498-
* substituting the REPLACEMENT CHARACTER */
3499-
if (UNLIKELY(uv == 0 && *s != '\0')) {
3500-
uv = UNICODE_REPLACEMENT;
3501-
}
3493+
UV uv;
3494+
(void) c9strict_utf8_to_uv(s, send, &uv, &retlen);
35023495

35033496
if (uv >= FIRST_IN_PLANE1) { /* Requires a surrogate pair */
35043497

0 commit comments

Comments
 (0)