Using UTF-8 charset with PHP - are mb functions required?

后端 未结 8 2121
不知归路
不知归路 2021-01-01 02:05

These past few days I\'ve been working toward converting my PHP code base from latin1 to UTF-8. I\'ve read the two main solutions are to either replace the single byte funct

8条回答
  •  清歌不尽
    2021-01-01 02:26

    As far as I understand the issue, as long as all your data is 100% in utf-8 - and that means user input, database, and also the encoding of the PHP files themselves if you have special characters in them - this is true true for search and comparison operations. As @ntd points out, a non-multibyte strlen() will produce wrong results when run on a string that contains multibyte characters.

    THis is a great article on the basics of encoding.

提交回复
热议问题