diff options
author | Karl Williamson <khw@cpan.org> | 2017-08-10 15:27:15 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-09-09 23:05:12 -0600 |
commit | ffd0a9d37933ebd091d566f4007611170713baf0 (patch) | |
tree | 86da2b2e55306997d82bdf25554aad0069d18e72 /utf8.c | |
parent | fd43f63c0d99146b70be91253babfaef4d56d184 (diff) | |
download | perl-ffd0a9d37933ebd091d566f4007611170713baf0.tar.gz |
utf8.c: Use mnemonic for repeatedly used number
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -2388,10 +2388,12 @@ Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen) *d++ = UTF8_TWO_BYTE_LO(UNI_TO_NATIVE(uv)); continue; } + #define FIRST_HIGH_SURROGATE UNICODE_SURROGATE_FIRST #define LAST_HIGH_SURROGATE 0xDBFF #define FIRST_LOW_SURROGATE 0xDC00 #define LAST_LOW_SURROGATE UNICODE_SURROGATE_LAST +#define FIRST_IN_PLANE1 0x10000 /* This assumes that most uses will be in the first Unicode plane, not * needing surrogates */ @@ -2410,13 +2412,13 @@ Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen) } p += 2; uv = ((uv - FIRST_HIGH_SURROGATE) << 10) - + (low - FIRST_LOW_SURROGATE) + 0x10000; + + (low - FIRST_LOW_SURROGATE) + FIRST_IN_PLANE1; } } #ifdef EBCDIC d = uvoffuni_to_utf8_flags(d, uv, 0); #else - if (uv < 0x10000) { + if (uv < FIRST_IN_PLANE1) { *d++ = (U8)(( uv >> 12) | 0xe0); *d++ = (U8)(((uv >> 6) & 0x3f) | 0x80); *d++ = (U8)(( uv & 0x3f) | 0x80); |