diff options
author | midipix <writeonce@midipix.org> | 2017-11-11 16:02:12 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2017-11-11 16:02:12 -0500 |
commit | 13e6f2c0fd263fb501a74cf3d53889661db94ee0 (patch) | |
tree | 023a403ad824f07ff1600d75f3b960b3de908c35 | |
parent | 4e34968ba50cd47469785ad7dbb4280d2b49d460 (diff) | |
download | ntapi-13e6f2c0fd263fb501a74cf3d53889661db94ee0.tar.bz2 ntapi-13e6f2c0fd263fb501a74cf3d53889661db94ee0.tar.xz |
unicode: __utf16_to_utf8_handler_4bytes(): fix conversion logic.
-rw-r--r-- | src/unicode/ntapi_uc_unicode_conversion_from_utf16.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c b/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c index 95e0330..2c9e99b 100644 --- a/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c +++ b/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c @@ -160,41 +160,45 @@ static int32_t __fastcall __utf16_to_utf8_handler_4bytes(nt_utf16_callback_args dst = (uint8_t *)args->dst; /* low two bytes */ - wx = *src; - wx <<= 10; - wx >>= 10; - - wy_low = *src; - wy_low <<= 6; - wy_low >>= 12; - - /* (surrogate pair) */ - src++; - - /* high two bytes */ - wy_high = *src; + wy_high = *src; wy_high <<= 14; wy_high >>= 10; - wz = *src; + wz = *src; wz <<= 10; wz >>= 12; - wz <<= 2; - ww = *src; + ww = *src; ww <<= 6; ww >>= 12; - uuuuu = ww + 1; - u_high = uuuuu >> 2; - u_low = ((uuuuu << 14) >> 10); + /* (surrogate pair) */ + src++; + + /* high two bytes */ + wx = *src; + wx <<= 10; + wx >>= 10; + + wy_low = *src; + wy_low <<= 6; + wy_low >>= 12; + + /* uuuuu */ + uuuuu = ww + 1; + u_low = uuuuu; + u_low >>= 2; + + u_high = uuuuu; + u_high <<= 14; + u_high >>= 10; /* 1st byte: 11110uuu */ - *dst = (char)(0xF0 | u_high); + *dst = (char)(0xF0 | u_low); dst++; /* 2nd byte: 10uuzzzz */ - *dst = (char)(0x80 | u_low | wz); + *dst = (char)(0x80 | u_high | wz); dst++; /* 3rd byte: 10yyyyyy */ |