Str_getcsv broken, clicks of diacritics?

I have this code in a UTF-8 encoded file:

<?php setlocale(LC_ALL, 'cs_CZ.utf8'); //Can be commented out without effect. $input = "Štěpán,Šafránek"; $result = str_getcsv($input); echo $result[0]; //output = "těpán"; echo $result[1]; //output = "afránek"; ?> 

Notice the trimmed lines that cause echoes.

It also works:

 <?php setlocale(LC_ALL, 'cs_CZ.utf8'); //Can be commented out without effect. $input = "aaaŠtěpán,aaaŠafránek"; $result = str_getcsv($input); echo $result[0]; //output = "aaaŠtěpán"; echo $result[1]; //output = "aaaŠafránek"; ?> 

Since the input line is part of the script, there should be no encoding problems, right? The language is installed correctly, right?

So what's wrong? My solution is that str_getcsv () is just broken. Any alternative way to parse CSV?

Interestingly, on Windows, this works great, but on Linux, I see this behavior.

A related question, but the resolutions mentioned there did not help: PHP str_getcsv removes umlauts

+2
php csv diacritics
source share

No one has answered this question yet.

See similar questions:

8
fgetcsv eats the first letter of the string if it is Umlaut
7
PHP str_getcsv removes umlauts

or similar:

1065
Link. What does this error mean in PHP?
393
How to remove diacritics (accents) from a string in .NET?
368
Removing accents / diacritics in a string in JavaScript
162
Does Microsoft Excel manage diacritics in CSV files?
65
Latex ads with UTF-8 (or at least German umlauts)
8
fgetcsv eats the first letter of the string if it is Umlaut
7
PHP str_getcsv removes umlauts
5
How to send plain XML to SOAP response?
one
What can break the encodings between the database and the display?
one
How to avoid php violation of umlaut characters when loading an xml file?

All Articles