Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-16BE not exported correctly #309

Open
suckerp opened this issue Jul 3, 2023 · 1 comment
Open

UTF-16BE not exported correctly #309

suckerp opened this issue Jul 3, 2023 · 1 comment

Comments

@suckerp
Copy link

suckerp commented Jul 3, 2023

HI,

I'm trying to export a JSON to later import into SQL Server. For that I need to use a UTF-16BE encoded file.

My problem is that when I try to convert it to UTF-16BE (utf16be) I get ANSI encoded file with only NUL entries. When I convert it into utf16 (le) it works correctly.
Here's what I'm doing.

//to write the data from the arry into a UTF-8 File I use the standard writeFile function.
fs.writeFile(filename, JSON.stringify(data, null, 4), 'utf8')

//Input opens the previously written UTF-8 encoded file and the it should be converted into UTF-16BE but here's where I run into problems
fs.createReadStream(input)
.pipe(iconv.decodeStream('utf8'))
.pipe(iconv.encodeStream('utf16be'))
.pipe(fs.createWriteStream(output))

grafik

Like I said before when I use something like utf16 or utf16le instead of utf16be I get the correct output file for that encoding. But not for utf16be.

Is anybody else having the same issue with the UTF-16BE encoding?

@ashtuchkin
Copy link
Owner

ashtuchkin commented Jul 3, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants