2 ms·
IMHO this is something Java got totally right. With many other languages Unicode is some afterthought. Ever tried Unicode things in php? It's horrible. Having
by axod 18y ago
IMHO this is something Java got totally right.
With many other languages Unicode is some afterthought. Ever tried Unicode things in php? It's horrible.
Having all strings as Unicode is fantastic. If you're dealing with something else and can't afford the memory, then sure - roll your own with byte[] arrays. Not a big deal.
- ars 18y agoI use unicode in php routinely. It works fine. If you need sub-string manipulations add mb_ to stuff (and if you are manipulating an entire string you need do nothing special). And if adding mb_ is too much trouble use mbstring.func_overload. UTF-8 only of course. All the other encodings should never be used anywhere. With UTF-8 the majority of the time you can use regular functions - for example trim() works just fine on a UTF-8 string.
- neilc 18y agoI'm curious why Java doesn't use UTF-8 encoding by default; that would offer much of the memory savings the parent poster is talking about, if the data is mostly ASCII anyway.
- axod 18y agobecause it'd have an extreme effect on performance? UTF-8 is great in terms of size, but terrible in terms of speed.
- neilc 18y agoHow "extreme" are we talking about? Some empirical data would be helpful. I'd also be curious to see data about what % of the characters in all the strings in a typical Java program aren't in 7-bit ASCII. I wouldn't be surprised if 7-bit ASCII characters are a large majority of the total, which makes the case for UTF-16 less compelling.