Character set conversion

I want to convert "Cool" to the original string. The original line is cool . ('backquote)

-2
source share
2 answers

It seems that you just forgot to specify the character encoding correctly .

Because Ò€œ this is what you get when the character " (U + 201C) encoded in UTF-8 (0xE2809C) is interpreted with a single-byte character encoding such as Windows-1252 (default character encoding in some browsers) , where 0xE2, 0x80 and 0x9C represent the characters Γ’ , € and Ε“ respectively.

Therefore, just make sure to set the character encoding correctly. Or, if you really want to use Windows-1252 as the encoding of the output character, you can convert your UTF-8 data using mb_convert_encoding , iconv or similar functions.

+2
source

There are many character encoding functions in PHP, especially if you have access to multibyte string functions . (mb_string is fortunately included for most PHP installations.)

What you need to do is convert the encoding of the source string to the desired encoding, but since I don't know what encoding was used / required, I can suggest that you can try using mb_convert_encoding , perhaps after using mb_detect_encoding in the source string.

By the way, I highly recommend storing all data in UTF-8 (text files, HTML encoding, data connections / data, etc.), since you will make your life much easier.

0
source

Source: https://habr.com/ru/post/1274290/


All Articles