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

Fix multibyte bug on utf-8 import #6

Closed
wants to merge 0 commits into from

Conversation

filkaris
Copy link

When importing a csv file, we currently take the first 1024 bytes as a sample via file_get_contents, and try to detect its encoding.

When, however, the file is in utf-8 encoding, there is a chance that the first 1024 bytes split a multibyte character. As a result the encoding is not recognized as utf-8.

This fixes that issue by using php's mb_substr function.

@ralfbecker
Copy link
Member

I'd rather use the following:

$sample = mb_substr(file_get_contents($content['file']['tmp_name'], false, null, 0, 2048), 1024);

Please do not assign to $sample twice, as this is flagged as potential mistake in Netbeans.

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

Successfully merging this pull request may close these issues.

2 participants