summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/unicode/ntapi_uc_unicode_conversion_from_utf16.c46
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 */