Search code examples
phputf-8multibyte

Should i refactor all my framework to use mbstring functions?


I currently use mbstring.func_overload = 7 to get working with UTF-8 charset.

I am thinking to refactor all func call to use mb_* functions.

Do you think this is necessarily, or with PHP 6 or newer version the multibyte problem will be solved in another way?


Solution

  • for string that are utf-8 (of course)

    Yes, of course. There are many things you can do with strings though. UTF-8 is backwards compatible with ASCII. If you only want to operate on the ASCII characters of a string, it may or may not make a difference. It depends on what you need to do with your strings.

    If you want a direct answer: No, you should not refactor every function to an mb_ function, because it's likely overkill. Should you check your use cases whether a multi-byte UTF-8 string may impact results and refactor accordingly? Yes.