PHP: Problems converting “’” character from ISO-8859-1 to UTF-8

后端 未结 2 889
别那么骄傲
别那么骄傲 2021-02-04 20:16

I\'m having some issues with using PHP to convert ISO-8859-1 database content to UTF-8. I am running the following code to test:

// Connect to a latin1 charset d         


        
2条回答
  •  猫巷女王i
    2021-02-04 21:08

    U+2019 RIGHT SINGLE QUOTATION MARK is not a character in ISO-8859-1. It is a character in windows-1252, as 0x92. The actual ISO-8859-1 character 0x92 is a rarely-used C1 control character called "Private Use 2".

    It is very common to mislabel Windows-1252 text data with the charset label ISO-8859-1. Many web browsers and e-mail clients treat the MIME charset ISO-8859-1 as Windows-1252 characters in order to accommodate such mislabeling but it is not standard behaviour and care should be taken to avoid generating these characters in ISO-8859-1 labeled content.

    It appears that this is what's happening here. Change "ISO-8859-1" to "windows-1252".

提交回复
热议问题