summaryrefslogtreecommitdiffhomepage
path: root/src/argv
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-08-29 02:37:38 +0000
committermidipix <writeonce@midipix.org>2019-08-29 02:37:38 +0000
commitcef942ef31af468786ba23ed27e15bd03dcca4a0 (patch)
tree1334a29845921ea86dc5852db93ea192a59c5513 /src/argv
parent7d967d97d088e75dfb0974116efc6065e58ad19c (diff)
downloadntapi-cef942ef31af468786ba23ed27e15bd03dcca4a0.tar.bz2
ntapi-cef942ef31af468786ba23ed27e15bd03dcca4a0.tar.xz
__ntapi_tt_array_convert_utf16_to_utf8(): fix conversion logic (cf. 13e6f2c0).
Diffstat (limited to 'src/argv')
-rw-r--r--src/argv/ntapi_tt_array_utf16.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/argv/ntapi_tt_array_utf16.c b/src/argv/ntapi_tt_array_utf16.c
index fa0892d..2e1bc35 100644
--- a/src/argv/ntapi_tt_array_utf16.c
+++ b/src/argv/ntapi_tt_array_utf16.c
@@ -230,46 +230,47 @@ int32_t __stdcall __ntapi_tt_array_convert_utf16_to_utf8(
/* to: 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx (utf-8) */
/* low two bytes */
- wx = *wch;
- wx <<= 10;
- wx >>= 10;
-
- wy_low = *wch;
- wy_low <<= 6;
- wy_low >>= 12;
-
- /* (surrogate pair) */
- wch++;
-
- /* high two bytes */
- wy_high = *wch;
+ wy_high = *wch;
wy_high <<= 14;
wy_high >>= 10;
- wz = *wch;
+ wz = *wch;
wz <<= 10;
wz >>= 12;
- wz <<= 2;
- ww = *wch;
+ ww = *wch;
ww <<= 6;
ww >>= 12;
- uuuuu = ww + 1;
- u_high = uuuuu >> 2;
- u_low = ((uuuuu << 14) >> 10);
+ /* (surrogate pair) */
+ wch++;
+
+ /* high two bytes */
+ wx = *wch;
+ wx <<= 10;
+ wx >>= 10;
+
+ wy_low = *wch;
+ 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 */
- *ch = (char)(0xF0 | u_high);
- ch++;
+ *ch++ = (char)(0xF0 | u_low);
/* 2nd byte: 10uuzzzz */
- *ch = (char)(0x80 | u_low | wz);
- ch++;
+ *ch++ = (char)(0x80 | u_high | wz);
/* 3rd byte: 10yyyyyy */
- *ch = (char)(0x80 | wy_low | wy_high);
- ch++;
+ *ch++ = (char)(0x80 | wy_low | wy_high);
/* 4th byte: 10xxxxxx */
*ch = (char)(0x80 | wx);