Answer the question
In order to leave comments, you need to log in
What encoding should a CSV file have for correct reading through php?
After uploading the CSV file to the server and trying to display its contents, I experience problems with the encoding and see "cracks".
Further work with these data is required.
What encoding should be specified for the csv file before uploading to the server, so that php correctly displays its contents?
Maybe you can just specify in the code what encoding is used?
If I just needed to display the content, I would write:
for the appropriate encoding.
But in the future I work with the contents of the file (its line-by-line moving to the data array). Which complicate the task.
header('Content-Type: text/html; charset=UTF-8');
Answer the question
In order to leave comments, you need to log in
Now it is customary to write php code in utf-8 and give site pages in utf-8.
If the csv file is in a different encoding, recode it using iconv or similar.
$str = iconv( "Windows-1252", "UTF-8", $str );
But in the future I work with the contents of the file (its line-by-line moving to the data array). Which complicate the task.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question