문제

When trying to import a CSV file, Arabic characters vanish when running fgetcsv, yet when I print the output from fopen, the Arabic characters are displayed just fine. The strange thing is that this is only happening in our production environment and not in my development environment, where fgetcsv reads the Arabic characters just fine. Is there some server setting that's not set correctly in production?

도움이 되었습니까?

해결책

fgetcsv() makes assumptions about the file's encoding based on the system locale. As the PHP manual states:

Locale setting is taken into account by this function. If LANG is e.g. en_US.UTF-8, files in one-byte encoding are read wrong by this function.

You might want to compare the locale settings on your two machines and either permanently change it on one of them, or use something like setlocale(LC_ALL, 'ar_AE.utf8') (the second argument would obviously depend on your file's encoding) before your fgetcsv().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top