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

no support for source encoding UTF16 (LE/BE) #77

Open
FredoVelcro-zz opened this issue Jan 31, 2019 · 3 comments
Open

no support for source encoding UTF16 (LE/BE) #77

FredoVelcro-zz opened this issue Jan 31, 2019 · 3 comments

Comments

@FredoVelcro-zz
Copy link

Hello,
It does not work with UTF16 source encoding.
How to solve this ? (very hard task)
Thanks
Best regards

@voku
Copy link

voku commented Jun 17, 2019

@FredoVelcro you can use UTF8::encode(), it will use UTF8::str_detect_encoding() in the background to detect UTF-16 and UTF-32.

I hope this will help you && happy coding!

@BlackbitDevs
Copy link

BlackbitDevs commented Jan 29, 2025

Sadly UTF-16 can still not be read correctly with neitanod/forceutf8

@voku Does this mean that UTF8::encode() is a drop-in replacement for

public static function encode($encodingLabel, $text)
?

Hmm, with both ways I get the same result when reading this example-utf16le.csv. The column ItemDescPL contains some special characters which do not work (while the french special characters work perfectly with both libraries).
I get WBa[ciwo[ci antybakteryjne instead of Właściwości antybakteryjne

@BlackbitDevs
Copy link

Have resolved it with PHP Streams:

$fileHandle = fopen('file-csv','rb');
stream_filter_append($this->stream, 'convert.iconv.UTF-16LE/UTF-8');
$data = fgetcsv($handle, 0, ';');

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

3 participants