Reputation: 45
With cURL, I am saving files which have UTF-8 chars in the filename.
For example:
testšć.docx
When I used mb_detect_encoding()
, it returned ASCII.
So I tried to convert it with iconv
from ASCII to UTF-8 and from UTF-8 to UTF-8.
Neither option worked.
So does anyone has a suggestion on how I could keep UTF-8 file names?
Cheers!
Upvotes: 0
Views: 460
Reputation: 1850
In analogy with MySQL, when your MySQL data is encoded in UTF8 you should have php read it through a UTF8 "communication" so since your HTML data is in UTF8 i think your problem is (tho i don't have all your code to know if im correct) that you are not reading it as UTF8
Try adding this option to your cURL config:
curl_setopt( $ch, CURLOPT_ENCODING, "UTF-8" );
I don't know if this IS what you are missing, but in case not let me know and i'll update my answer...
Upvotes: 0
Reputation: 3781
Your file system (and operating system) must support UTF-8 encoded file names in order to retain files that use UTF-8 in the file name. If either do not support that, then the best option is to either convert them into a known transliteration, or discard (replace) the characters that cannot be converted.
Upvotes: 1