Skip to content

Commit

Permalink
utf16_to8:onvert to preferred utf8_to_uv_flags()
Browse files Browse the repository at this point in the history
from utf8n_to_uvchr()
  • Loading branch information
khwilliamson committed Jan 7, 2025
1 parent 7911101 commit 2b1fcb2
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -3438,15 +3438,10 @@ Perl_utf8_to_utf16_base(pTHX_ U8* s, U8* d, Size_t bytelen, Size_t *newlen,

while (s < send) {
STRLEN retlen;
UV uv = utf8n_to_uvchr(s, send - s, &retlen,
/* No surrogates nor above-Unicode */
UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE);

/* The modern method is to keep going with malformed input,
* substituting the REPLACEMENT CHARACTER */
if (UNLIKELY(uv == 0 && *s != '\0')) {
uv = UNICODE_REPLACEMENT;
}
UV uv;
utf8_to_uv_flags(s, send, &uv, &retlen,
/* No surrogates nor above-Unicode */
UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE);

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

Expand Down

0 comments on commit 2b1fcb2

Please sign in to comment.