There is a script that is trying to determine the encoding and change to WINDOWS-1251.
Here is the main piece:
$from = mb_detect_encoding($cell,"auto"); print_r($from);echo"\n"; $cell = iconv( $from, "WINDOWS-1251//IGNORE", $cell ); Who guessed, it happens to every cell of one of the xls file.
In general, the second line with a print, shows that ASCII.
The result shows the scrubber , which indicates a wrong definition of the encoding and further actions.
I was a long time, perhaps not enough, googled, and came to check these two lines:
print_r(mb_list_encodings()); print_r(mb_detect_order()); The second gives modest massif:
Array ( [0] => ASCII [1] => UTF-8 ) The first is much larger . And depending on the version of PHP, the list slightly changes.
At first I sinned on it, but then I opened the file in OpenOffice, which did not even suggest choosing encodings.
I installed which extension, where I chose латин-1 => кирилица , and everything is good.
That is latin-1 , I thought, but it is, as I understand it, in any version .
I wanted to get the first line of the list and mb_detect_encoding it in mb_detect_encoding , but there still is some sort of order .
In general, I'm confused already ...
Tell me how to properly determine the encoding?
Or add on my sabzh, if you do not get a complete porridge.
Thank.
UPD1 :
Today I tried:
print_r(mb_check_encoding($cell,"WINDOWS-1251")); print_r(mb_check_encoding($cell,"ASCII")); print_r(mb_check_encoding($cell,"WINDOWS-1252")); print_r(mb_check_encoding($cell,"UTF-8")); print_r(mb_check_encoding($cell,"ISO-8859-1")); All give 1 .
What does mean?
Is the encoding wrong or any suitable ??
mb_detect_order(mb_list_encodings()); print_r(mb_detect_order());mb_detect_order(mb_list_encodings()); print_r(mb_detect_order());- ilyaplot