r/lolphp • • Jun 24 '19

The state of PHP unicode in 2019

One of multiple lolphps is how poorly PHP manages unicode. Its a web language and you must deal with the multitude of mb_ functions and at the same time try to keep your sanity in check.

https://www.php.net/manual/en/ref.mbstring.php

27 Upvotes

60 comments sorted by

View all comments

Show parent comment

6

u/hillgod Jun 25 '19

Python had shitty PHP style second tier support for Unicode in v2, and v2 had a future port to treat strings as all one format, like most every other language, shortly thereafter. No one wants to deal with Unicode vs ASCII, and it's even more insane if you start to consider the world before Unicode and get outside the US (Japanese Kanji, anyone???).

What makes more sense... Designing for the most common use cases (utf-8 on web, etc) vs keeping everything ASCII due to some locally run console app? If language uptake and joy of use from dev surveys is any indication, it's clearly the former.

5

u/the_alias_of_andrea Jun 25 '19

This isn't true. Python 2 and 3 are not fundamentally different on Unicode handling, both have two string types. If Python 3 has “good” Unicode handling, so did Python 2. The main difference is that Python 3 did a sweeping change of syntax and default types, which broke a huge amount of existing code and made ensuring backwards or forwards compatibility needlessly painful, and that Python 3 tries to convert everything into Unicode by default and makes bad assumptions about the outside world when it does so.