When converting a string from the "utf-8" encoding to "windows-1251", iconv () yields nothing. I think this is because of characters like "☕". How to solve it?
1 answer
Do not use windows-1251 encoding, it is almost 2017 in the yard.
PS And if you strongly need, then do it like this, for example:
$str = iconv('UTF-8', 'CP1251//IGNORE', $str); If you add the // TRANSLIT line to out_charset, the transliteration mode is turned on. This means that in case a symbol cannot be represented in the required encoding, it will be replaced with one or several symbols that are closest in appearance. If you add the string // IGNORE, then characters that cannot be represented in the required encoding will be deleted. If the above parameters are missing, if there are incorrect characters, the str string will be truncated to the first such character, an error of the E_NOTICE level will be generated and the function will return FALSE.
- oneEverything is working. PHP is used not for traditional purposes, but for creating GUI programs. In the programming environment in which I work there is support only for Windows-1251. So you have to use it. - Mikhail Tikhonov
- I remember years 6-7 watching tutorials and saying there.
Не используйте utfis unreliable, etc., use only windows-1251 xD Years go, everything changes)) - Alexey Shimansky