Yasuhiro Matsumoto
2b184d4b97
patch 9.1.2124: blob2str() does not handle UTF-16 encoding
...
Problem: blob2str() does not handle UTF-16 encoding
(Hirohito Higashi)
Solution: Refactor the code and fix remaining issues, see below
(Yasuhiro Matsumoto).
blob2str() function did not properly handle UTF-16/UCS-2/UTF-32/UCS-4
encodings with endianness suffixes (e.g., utf-16le, utf-16be, ucs-2le).
The encoding name was canonicalized too aggressively, losing the
endianness information needed by iconv.
This change include few fixes:
- Preserve the raw encoding name with endianness suffix for iconv calls
- Normalize encoding names properly: "ucs2be" → "ucs-2be", "utf16le" →
"utf-16le"
- For multi-byte encodings (UTF-16/32, UCS-2/4), convert the entire blob
first, then split by newlines
convert_string() cannot handle UTF-16 because it uses string_convert()
which expects NUL-terminated strings. UTF-16 contains 0x00 bytes within
characters (e.g., "H" = 0x48 0x00), causing premature termination.
Therefore, for UTF-16/32 encodings, the fix uses string_convert_ext()
with an explicit input length to convert the entire blob at once.
The code appends two NUL bytes (ga_append(&blob_ga, NUL) twice) because
UTF-16 requires a 2-byte NUL terminator (0x00 0x00), not a single-byte
NUL.
- src/strings.c: Add from_encoding_raw to preserve endianness, special
handling for UTF-16/32 and UCS-2/4
- src/mbyte.c: Fix convert_setup_ext() to use == ENC_UNICODE instead of
& ENC_UNICODE. The bitwise AND was incorrectly treating UTF-16/UCS-2
(which have ENC_UNICODE + ENC_2BYTE etc.) as UTF-8, causing iconv
setup to be skipped.
fixes: #19198
closes : #19246
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com >
Signed-off-by: Christian Brabandt <cb@256bit.org >
2026-01-31 15:59:01 +00:00
..
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-31 15:59:01 +00:00
2026-01-08 21:39:15 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-12-13 17:42:59 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-10 18:14:13 +00:00
2026-01-19 18:07:28 +00:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2025-11-09 19:23:50 +00:00
2025-12-07 19:12:33 +01:00
2025-11-09 19:23:50 +00:00
2025-08-06 12:44:36 +02:00
2026-01-18 20:50:11 +00:00
2025-09-14 11:05:46 -04:00
2026-01-11 18:45:42 +00:00
2026-01-25 18:17:40 +00:00
2025-08-10 10:28:16 +02:00
2026-01-31 09:42:05 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-26 19:40:37 +00:00
2025-11-01 16:15:39 +00:00
2026-01-25 17:59:30 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-11 18:23:20 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-07 21:33:28 +00:00
2025-11-27 21:28:05 +00:00
2025-06-27 21:10:35 +02:00
2026-01-26 19:40:37 +00:00
2025-03-28 19:11:11 +01:00
2025-11-09 19:23:50 +00:00
2025-12-17 23:24:57 +01:00
2025-12-09 13:27:00 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-25 15:23:07 +00:00
2026-01-29 19:18:10 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-28 21:58:28 +00:00
2025-08-10 10:28:16 +02:00
2025-11-09 19:23:50 +00:00
2025-08-10 10:28:16 +02:00
2025-11-09 19:23:50 +00:00
2025-08-10 10:28:16 +02:00
2025-05-19 19:34:44 +02:00
2025-08-06 12:44:36 +02:00
2025-10-06 17:56:20 +00:00
2026-01-08 19:35:38 +00:00
2025-12-17 23:24:57 +01:00
2025-12-27 14:07:21 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-25 18:05:43 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-25 15:23:07 +00:00
2025-11-09 19:23:50 +00:00
2025-12-20 16:54:07 +00:00
2026-01-26 19:56:27 +00:00
2025-11-09 19:23:50 +00:00
2026-01-25 15:46:09 +00:00
2025-11-09 19:23:50 +00:00
2025-11-11 17:52:45 +00:00
2026-01-18 20:50:11 +00:00
2025-10-12 15:31:37 +00:00
2025-11-09 19:23:50 +00:00
2025-12-02 20:42:53 +00:00
2025-12-26 16:01:31 +00:00
2026-01-07 21:33:28 +00:00
2025-11-09 19:23:50 +00:00
2025-12-20 15:24:57 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-12-15 21:52:32 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-26 20:12:28 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-28 20:37:16 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-12-13 18:23:54 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-12-11 21:13:35 +01:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2025-11-09 19:23:50 +00:00
2026-01-07 20:32:22 +00:00
2025-11-09 19:23:50 +00:00
2026-01-25 18:05:43 +00:00
2026-01-25 15:52:46 +00:00
2025-11-11 16:47:24 +00:00
2024-11-28 21:45:39 +01:00
2024-11-28 21:45:39 +01:00
2025-08-20 20:23:29 +02:00
2025-08-20 20:23:29 +02:00
2026-01-19 18:07:28 +00:00
2025-10-07 19:19:43 +00:00
2025-10-07 19:19:43 +00:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2025-08-18 21:40:40 +02:00
2025-08-18 21:40:40 +02:00
2026-01-19 18:07:28 +00:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2025-06-29 17:51:33 +02:00
2025-06-30 20:28:46 +02:00
2025-06-24 21:17:25 +02:00
2025-06-24 21:17:25 +02:00
2026-01-19 18:07:28 +00:00
2025-07-09 19:43:51 +02:00
2025-07-09 19:43:51 +02:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2025-06-23 19:52:42 +02:00
2025-06-23 19:52:42 +02:00
2025-11-09 19:23:50 +00:00
2025-11-25 22:04:58 +00:00
2025-12-03 19:22:13 +00:00
2025-11-09 19:23:50 +00:00
2024-09-17 19:12:03 +02:00
2024-09-17 19:12:03 +02:00
2026-01-19 18:07:28 +00:00
2024-09-17 19:03:16 +02:00
2024-09-17 19:03:16 +02:00
2026-01-26 19:40:37 +00:00
2026-01-26 19:40:37 +00:00
2024-09-15 20:03:05 +02:00
2024-09-15 20:03:05 +02:00