There is a script that creates files and has the utf-8 encoding. With Russian characters, file names have krakozyabry. How to solve it? Tests on Linux and Windows
- oneI wonder why you are creating such file names? With Russian letters in the names. - Visman
- Are you sure that your system locale is UTF-8 (at least in Linux)? - Boris
- @ Boris Well, they asked for support, locale c1251, but something doesn’t plow - Mikhail Khalupov
- @ Mikhail Khalupov: do not plow even using iconv? or what exactly does not plow? - Boris
- At least two duplicates of this question exist: - en . - Anatol Belski
|
1 answer
Use the iconv function. When creating a file, for example:
<?php $filename = @iconv("utf-8", "windows-1251", 'ИМЯ_ФАЙЛА_НА РУССКОМ'); file_put_contents($filename, 'КАКОЙ-ТО ТЕКСТ'); ?> UPD: The final encoding may vary.
- On linux also windows-1251 encoding is used? :) - Visman
- It depends on the environment selected. More often not, but with a clumsy setting - yes. I have had several times, when ordering a VPS, that is cp1251 encoding ( - GrayHoax
|