diff options
Diffstat (limited to 'enc/utf_16be.c')
-rw-r--r-- | enc/utf_16be.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/enc/utf_16be.c b/enc/utf_16be.c index d6e2c953b7..1e33c2ec7d 100644 --- a/enc/utf_16be.c +++ b/enc/utf_16be.c @@ -108,9 +108,8 @@ utf16be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED, OnigCodePoint code; if (UTF16_IS_SURROGATE_FIRST(*p)) { - code = ((((p[0] - 0xd8) << 2) + ((p[1] & 0xc0) >> 6) + 1) << 16) - + ((((p[1] & 0x3f) << 2) + (p[2] - 0xdc)) << 8) - + p[3]; + code = ((((p[0] << 8) + p[1]) & 0x03ff) << 10) + + (((p[2] << 8) + p[3]) & 0x03ff) + 0x10000; } else { code = p[0] * 256 + p[1]; |