Skip to content

Commit

Permalink
as macos-12 has no UTF16LE, just UTF-16LE.... :(
Browse files Browse the repository at this point in the history
  • Loading branch information
kbkpbot committed Oct 2, 2024
1 parent f6679c3 commit d25f9e5
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 124 deletions.
20 changes: 10 additions & 10 deletions vlib/encoding/iconv/iconv.v
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn reverse_u32(src u32) u32 {
pub fn vstring_to_encoding(str string, tocode string) ![]u8 {
encoding_name := tocode.to_upper()
if encoding_name in ['UTF16', 'UTF32', 'UTF-16', 'UTF-32']! {
return error('please use UTF16LE/UTF16BE/UTF32LE/UTF32BE instead')
return error('please use UTF16-LE/UTF-16BE/UTF-32LE/UTF-32BE instead')
}
return conv(tocode, 'UTF-8', str.str, str.len)
}
Expand All @@ -28,7 +28,7 @@ pub fn vstring_to_encoding(str string, tocode string) ![]u8 {
pub fn encoding_to_vstring(bytes []u8, fromcode string) !string {
encoding_name := fromcode.to_upper()
if encoding_name in ['UTF16', 'UTF32', 'UTF-16', 'UTF-32']! {
return error('please use UTF16LE/UTF16BE/UTF32LE/UTF32BE instead')
return error('please use UTF16-LE/UTF-16BE/UTF-32LE/UTF-32BE instead')
}
mut dst := conv('UTF-8', fromcode, bytes.data, bytes.len)!
dst << 0 // add a tail zero, to build a vstring
Expand All @@ -50,13 +50,13 @@ pub fn create_utf_string_with_bom(src []u8, utf_type string) []u8 {
'UTF16LE', 'UTF-16LE' {
clone.prepend([u8(0xFF), 0xFE])
}
'UTF16BE', 'UFT16-BE' {
'UTF16BE', 'UTF-16BE' {
clone.prepend([u8(0xFE), 0xFF])
}
'UTF32LE', 'UFT32-LE' {
'UTF32LE', 'UTF-32LE' {
clone.prepend([u8(0xFF), 0xFE, 0, 0])
}
'UTF32BE', 'UFT32-BE' {
'UTF32BE', 'UTF-32BE' {
clone.prepend([u8(0), 0, 0xFE, 0xFF])
}
else {}
Expand Down Expand Up @@ -88,22 +88,22 @@ pub fn remove_utf_string_with_bom(src []u8, utf_type string) []u8 {
}
}
}
'UTF16BE', 'UFT16-BE' {
'UTF16BE', 'UTF-16BE' {
if clone.len > 2 {
if clone[0] == u8(0xFE) && clone[1] == u8(0xFF) {
clone.delete_many(0, 2)
}
}
}
'UTF32LE', 'UFT32-LE' {
'UTF32LE', 'UTF-32LE' {
if clone.len > 4 {
if clone[0] == u8(0xFF) && clone[1] == u8(0xFE) && clone[2] == u8(0)
&& clone[3] == u8(0) {
clone.delete_many(0, 4)
}
}
}
'UTF32BE', 'UFT32-BE' {
'UTF32BE', 'UTF-32BE' {
if clone.len > 4 {
if clone[0] == u8(0) && clone[1] == u8(0) && clone[2] == u8(0xFE)
&& clone[3] == u8(0xFF) {
Expand All @@ -121,7 +121,7 @@ pub fn remove_utf_string_with_bom(src []u8, utf_type string) []u8 {
pub fn write_file_encoding(path string, text string, encoding string, bom bool) ! {
encoding_name := encoding.to_upper()
if encoding_name in ['UTF16', 'UTF32', 'UTF-16', 'UTF-32']! {
return error('please use UTF16LE/UTF16BE/UTF32LE/UTF32BE instead')
return error('please use UTF-16LE/UTF-16BE/UTF-32LE/UTF-32BE instead')
}
encoding_bytes := vstring_to_encoding(text, encoding)!
if bom && encoding.to_upper().starts_with('UTF') {
Expand All @@ -136,7 +136,7 @@ pub fn write_file_encoding(path string, text string, encoding string, bom bool)
pub fn read_file_encoding(path string, encoding string) !string {
encoding_name := encoding.to_upper()
if encoding_name in ['UTF16', 'UTF32', 'UTF-16', 'UTF-32']! {
return error('please use UTF16LE/UTF16BE/UTF32LE/UTF32BE instead')
return error('please use UTF-16LE/UTF-16BE/UTF-32LE/UTF-32BE instead')
}
encoding_bytes := os.read_file_array[u8](path)
encoding_without_bom_bytes := remove_utf_string_with_bom(encoding_bytes, encoding)
Expand Down
92 changes: 18 additions & 74 deletions vlib/encoding/iconv/iconv_nix.c.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module iconv

import os

// Module iconv provides functions convert between vstring(UTF8) to/from different encodings.

#include <iconv.h>
Expand All @@ -18,56 +16,34 @@ fn conv(tocode string, fromcode string, src &u8, src_len int) ![]u8 {
return error('src length error')
}

// macos-12 workaround : UTF16LE<=>UTF16BE
mut is_src_swap := false
mut is_dst_swap := false

mut src_encoding := fromcode.to_upper()
mut dst_encoding := tocode.to_upper()

// As macos-12 has no UTF16LE/UTF16BE/UTF32LE/UTF32BE, change them to UTF-16LE/UTF-16BE/UTF-32LE/UTF-32BE
match src_encoding {
'UTF16LE' { src_encoding = 'UTF-16LE' }
'UTF16BE' { src_encoding = 'UTF-16BE' }
'UTF32LE' { src_encoding = 'UTF-32LE' }
'UTF32BE' { src_encoding = 'UTF-32BE' }
else {}
}
match dst_encoding {
'UTF16LE' { dst_encoding = 'UTF-16LE' }
'UTF16BE' { dst_encoding = 'UTF-16BE' }
'UTF32LE' { dst_encoding = 'UTF-32LE' }
'UTF32BE' { dst_encoding = 'UTF-32BE' }
else {}
}

mut cd := C.iconv_open(dst_encoding.str, src_encoding.str)
if isize(cd) == -1 {
$if macos {
// macos-12 workaround: platform not support UTF16LE/UTF16BE, only UTF16, which is big-endian, followed by bytes swap
if src_encoding in ['UTF16LE', 'UTF-16LE'] {
src_encoding = 'UTF16'
is_src_swap = true
} else if src_encoding in ['UTF16BE', 'UTF-16BE'] {
src_encoding = 'UTF16'
}

if dst_encoding in ['UTF16LE', 'UTF-16LE'] {
dst_encoding = 'UTF16'
is_dst_swap = true
} else if dst_encoding in ['UTF16BE', 'UTF-16BE'] {
dst_encoding = 'UTF16'
}
cd = C.iconv_open(dst_encoding.str, src_encoding.str)
if isize(cd) == -1 {
os.system('/usr/bin/which iconv')
os.system('/usr/bin/iconv --list') // debug
return error('macos can\'t convert from ${src_encoding} to ${dst_encoding}')
}
} $else {
return error('platform can\'t convert from ${src_encoding} to ${dst_encoding}')
}
return error('platform can\'t convert from ${src_encoding} to ${dst_encoding}')
}
defer { C.iconv_close(cd) }

mut dst := []u8{len: (src_len + 1) * 4} // this should be enough to hold the dst encoding string

mut src_ptr := &u8(src)
if is_src_swap {
// macos-12 workaround: UTF16LE=>UTF16BE
mut src_swap := []u8{len: src_len}
unsafe { vmemcpy(src_swap.data, src, src_len) }
mut sptr := unsafe { &u16(src_swap.data) }
for i in 0 .. src_len / 2 {
unsafe {
sptr[i] = reverse_u16(sptr[i])
}
}
src_ptr = &u8(src_swap.data)
}
mut dst_ptr := &u8(dst.data)
mut src_left := usize(src_len)
mut dst_left := usize(dst.len)
Expand All @@ -78,37 +54,5 @@ fn conv(tocode string, fromcode string, src &u8, src_len int) ![]u8 {

// resize dst buf to real length
dst.trim(dst.len - int(dst_left))

if dst_encoding in ['UTF16', 'UTF-16']! {
// To compatible with Windows(Little Endian default), remove the first FFFE/FEFF(BOM)
if dst.len <= 2 {
return dst // error('convert to UTF16 length too short? no BOM?')
}
if (dst[0] == u8(0xFF) && dst[1] == u8(0xFE)) || (dst[0] == u8(0xFE) && dst[1] == u8(0xFF)) {
dst.delete_many(0, 2)
}
}

if dst_encoding in ['UTF32', 'UTF-32']! {
// remove the first FFFE0000/0000FEFF(BOM)
if dst.len <= 4 {
return dst // error('convert to UTF32 length too short? no BOM?')
}
if (dst[0] == u8(0xFF) && dst[1] == u8(0xFE) && dst[2] == u8(0x00) && dst[3] == u8(0x00))
|| (dst[0] == u8(0x00) && dst[1] == u8(0x00) && dst[2] == u8(0xFE)
&& dst[3] == u8(0xFF)) {
dst.delete_many(0, 4)
}
}

if is_dst_swap {
// macos-12 workaround: UTF16BE=>UTF16LE
mut dptr := unsafe { &u16(dst.data) }
for i in 0 .. dst.len / 2 {
unsafe {
dptr[i] = reverse_u16(dptr[i])
}
}
}
return dst
}
74 changes: 37 additions & 37 deletions vlib/encoding/iconv/iconv_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import encoding.iconv
import os

fn test_vstring_to_encoding() {
empty_utf8 := iconv.vstring_to_encoding('', 'UTF8')!
empty_utf8 := iconv.vstring_to_encoding('', 'UTF-8')!
assert empty_utf8 == []

abc_utf8 := iconv.vstring_to_encoding('abc', 'UTF8')!
abc_utf8 := iconv.vstring_to_encoding('abc', 'UTF-8')!
assert abc_utf8 == [u8(97), 98, 99]

abc_utf16le := iconv.vstring_to_encoding('abc', 'UTF16LE')!
abc_utf16le := iconv.vstring_to_encoding('abc', 'UTF-16LE')!
assert abc_utf16le == [u8(97), 0, 98, 0, 99, 0]

abc_utf16be := iconv.vstring_to_encoding('abc', 'UTF16BE')!
abc_utf16be := iconv.vstring_to_encoding('abc', 'UTF-16BE')!
assert abc_utf16be == [u8(0), 97, 0, 98, 0, 99]

abc_utf32le := iconv.vstring_to_encoding('abc', 'UTF32LE')!
abc_utf32le := iconv.vstring_to_encoding('abc', 'UTF-32LE')!
assert abc_utf32le == [u8(97), 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0]

abc_utf32be := iconv.vstring_to_encoding('abc', 'UTF32BE')!
abc_utf32be := iconv.vstring_to_encoding('abc', 'UTF-32BE')!
assert abc_utf32be == [u8(0), 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99]

if abc_not_exist := iconv.vstring_to_encoding('abc', 'encoding_not_exist') {
Expand All @@ -33,24 +33,24 @@ fn test_vstring_to_encoding() {
}

fn test_encoding_to_vstring() {
empty_utf8 := iconv.encoding_to_vstring([], 'UTF8')!
empty_utf8 := iconv.encoding_to_vstring([], 'UTF-8')!
assert empty_utf8 == ''

abc_utf8 := iconv.encoding_to_vstring([u8(97), 98, 99], 'UTF8')!
abc_utf8 := iconv.encoding_to_vstring([u8(97), 98, 99], 'UTF-8')!
assert abc_utf8 == 'abc'

abc_utf16le := iconv.encoding_to_vstring([u8(97), 0, 98, 0, 99, 0], 'UTF16LE')!
abc_utf16le := iconv.encoding_to_vstring([u8(97), 0, 98, 0, 99, 0], 'UTF-16LE')!
assert abc_utf16le == 'abc'

abc_utf16be := iconv.encoding_to_vstring([u8(0), 97, 0, 98, 0, 99], 'UTF16BE')!
abc_utf16be := iconv.encoding_to_vstring([u8(0), 97, 0, 98, 0, 99], 'UTF-16BE')!
assert abc_utf16be == 'abc'

abc_utf32le := iconv.encoding_to_vstring([u8(97), 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0],
'UTF32LE')!
'UTF-32LE')!
assert abc_utf32le == 'abc'

abc_utf32be := iconv.encoding_to_vstring([u8(0), 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99],
'UTF32BE')!
'UTF-32BE')!
assert abc_utf32be == 'abc'

if abc_not_exist := iconv.encoding_to_vstring([u8(97), 98, 99], 'encoding_not_exist') {
Expand All @@ -70,22 +70,22 @@ fn test_encoding_to_vstring() {
fn test_create_utf_string_with_bom() {
// bug ? vfmt create strange format here
// vfmt off
assert iconv.create_utf_string_with_bom([u8(97), 98, 99], 'UTF8') == [u8(0xEF), 0xBB, 0xBF, 97, 98, 99]
assert iconv.create_utf_string_with_bom([u8(97), 0, 98, 0, 99, 0], 'UTF16LE') == [u8(0xFF), 0xFE, 97, 0, 98, 0, 99, 0]
assert iconv.create_utf_string_with_bom([u8(0), 97, 0, 98, 0, 99], 'UTF16BE') == [u8(0xFE), 0xFF, 0, 97, 0, 98, 0, 99]
assert iconv.create_utf_string_with_bom([u8(97), 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0], 'UTF32LE') == [u8(0xFF), 0xFE, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0]
assert iconv.create_utf_string_with_bom([u8(0), 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99], 'UTF32BE') == [u8(0), 0, 0xFE, 0xFF, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99]
assert iconv.create_utf_string_with_bom([u8(97), 98, 99], 'UTF-8') == [u8(0xEF), 0xBB, 0xBF, 97, 98, 99]
assert iconv.create_utf_string_with_bom([u8(97), 0, 98, 0, 99, 0], 'UTF-16LE') == [u8(0xFF), 0xFE, 97, 0, 98, 0, 99, 0]
assert iconv.create_utf_string_with_bom([u8(0), 97, 0, 98, 0, 99], 'UTF-16BE') == [u8(0xFE), 0xFF, 0, 97, 0, 98, 0, 99]
assert iconv.create_utf_string_with_bom([u8(97), 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0], 'UTF-32LE') == [u8(0xFF), 0xFE, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0]
assert iconv.create_utf_string_with_bom([u8(0), 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99], 'UTF-32BE') == [u8(0), 0, 0xFE, 0xFF, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99]
// vfmt on
}

fn test_remove_utf_string_with_bom() {
// bug ? vfmt create strange format here
// vfmt off
assert iconv.remove_utf_string_with_bom([u8(0xEF), 0xBB, 0xBF, 97, 98, 99], 'UTF8') == [u8(97), 98, 99]
assert iconv.remove_utf_string_with_bom([u8(0xFF), 0xFE, 97, 0, 98, 0, 99, 0], 'UTF16LE') == [u8(97), 0, 98, 0, 99, 0]
assert iconv.remove_utf_string_with_bom([u8(0xFE), 0xFF, 0, 97, 0, 98, 0, 99], 'UTF16BE') == [u8(0), 97, 0, 98, 0, 99]
assert iconv.remove_utf_string_with_bom([u8(0xFF), 0xFE, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0], 'UTF32LE') == [u8(97), 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0]
assert iconv.remove_utf_string_with_bom([u8(0), 0, 0xFE, 0xFF, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99], 'UTF32BE') == [u8(0), 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99]
assert iconv.remove_utf_string_with_bom([u8(0xEF), 0xBB, 0xBF, 97, 98, 99], 'UTF-8') == [u8(97), 98, 99]
assert iconv.remove_utf_string_with_bom([u8(0xFF), 0xFE, 97, 0, 98, 0, 99, 0], 'UTF-16LE') == [u8(97), 0, 98, 0, 99, 0]
assert iconv.remove_utf_string_with_bom([u8(0xFE), 0xFF, 0, 97, 0, 98, 0, 99], 'UTF-16BE') == [u8(0), 97, 0, 98, 0, 99]
assert iconv.remove_utf_string_with_bom([u8(0xFF), 0xFE, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0], 'UTF-32LE') == [u8(97), 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0]
assert iconv.remove_utf_string_with_bom([u8(0), 0, 0xFE, 0xFF, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99], 'UTF-32BE') == [u8(0), 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99]
// vfmt on
}

Expand All @@ -106,24 +106,24 @@ fn my_test_read_file_encoding_write_file_encoding(txt string, encoding string, b

fn test_read_file_encoding_write_file_encoding() ! {
// vfmt off
// UTF8
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF8',false,[u8(86), 229, 164, 167, 230, 179, 149, 229, 165, 189, 97, 98, 99])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF8',true,[u8(0xEF), 0xBB, 0xBF, 86, 229, 164, 167, 230, 179, 149, 229, 165, 189, 97, 98, 99])!
// UTF-8
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-8',false,[u8(86), 229, 164, 167, 230, 179, 149, 229, 165, 189, 97, 98, 99])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-8',true,[u8(0xEF), 0xBB, 0xBF, 86, 229, 164, 167, 230, 179, 149, 229, 165, 189, 97, 98, 99])!

// UTF16LE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF16LE',false,[u8(86), 0, 39, 89, 213, 108, 125, 89, 97, 0, 98, 0, 99, 0])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF16LE',true,[u8(0xFF), 0xFE, 86, 0, 39, 89, 213, 108, 125, 89, 97, 0, 98, 0, 99, 0])!
// UTF-16LE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-16LE',false,[u8(86), 0, 39, 89, 213, 108, 125, 89, 97, 0, 98, 0, 99, 0])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-16LE',true,[u8(0xFF), 0xFE, 86, 0, 39, 89, 213, 108, 125, 89, 97, 0, 98, 0, 99, 0])!

// UTF16BE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF16BE',false,[u8(0), 86, 89, 39, 108, 213, 89, 125, 0, 97, 0, 98, 0, 99])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF16BE',true,[u8(0xFE), 0xFF, 0, 86, 89, 39, 108, 213, 89, 125, 0, 97, 0, 98, 0, 99])!
// UTF-16BE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-16BE',false,[u8(0), 86, 89, 39, 108, 213, 89, 125, 0, 97, 0, 98, 0, 99])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-16BE',true,[u8(0xFE), 0xFF, 0, 86, 89, 39, 108, 213, 89, 125, 0, 97, 0, 98, 0, 99])!

// UTF32LE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF32LE',false,[u8(86), 0, 0, 0, 39, 89, 0, 0, 213, 108, 0, 0, 125, 89, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF32LE',true,[u8(0xFF), 0xFE, 0, 0, 86, 0, 0, 0, 39, 89, 0, 0, 213, 108, 0, 0, 125, 89, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0])!
// UTF-32LE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-32LE',false,[u8(86), 0, 0, 0, 39, 89, 0, 0, 213, 108, 0, 0, 125, 89, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-32LE',true,[u8(0xFF), 0xFE, 0, 0, 86, 0, 0, 0, 39, 89, 0, 0, 213, 108, 0, 0, 125, 89, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99, 0, 0, 0])!

// UTF32BE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF32BE',false,[u8(0), 0, 0, 86, 0, 0, 89, 39, 0, 0, 108, 213, 0, 0, 89, 125, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF32BE',true,[u8(0), 0, 0xFE, 0xFF, 0, 0, 0, 86, 0, 0, 89, 39, 0, 0, 108, 213, 0, 0, 89, 125, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99])!
// UTF-32BE
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-32BE',false,[u8(0), 0, 0, 86, 0, 0, 89, 39, 0, 0, 108, 213, 0, 0, 89, 125, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99])!
my_test_read_file_encoding_write_file_encoding('V大法好abc','UTF-32BE',true,[u8(0), 0, 0xFE, 0xFF, 0, 0, 0, 86, 0, 0, 89, 39, 0, 0, 108, 213, 0, 0, 89, 125, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99])!
// vfmt on
}
6 changes: 3 additions & 3 deletions vlib/encoding/iconv/iconv_windows.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ fn utf32_to_utf16(src &u8, src_len int, is_src_little_endian bool, is_dst_little
}
dst_idx++
} else {
return error('invalid utf32le encoding')
return error('invalid UTF-32LE encoding')
}
}
dst.trim(dst_idx * 2)
Expand Down Expand Up @@ -592,7 +592,7 @@ fn utf16_to_utf32(src &u8, src_len int, is_src_little_endian bool, is_dst_little
if w1 >= 0xD800 && w1 <= 0xDFFF {
if w1 < 0xDC00 {
if src_idx == src_len / 2 {
return error('invalid utf16le encoding')
return error('invalid UTF-16LE encoding')
}
unsafe {
w2 = sptr[src_idx]
Expand All @@ -611,7 +611,7 @@ fn utf16_to_utf32(src &u8, src_len int, is_src_little_endian bool, is_dst_little
dst_idx++
}
} else {
return error('invalid utf16le encoding')
return error('invalid UTF-16LE encoding')
}
} else {
t = w1
Expand Down

0 comments on commit d25f9e5

Please sign in to comment.