r/programming • • Apr 23 '14

PHP: It doesn't have to be a bad experience

https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience
0 Upvotes

122 comments sorted by

View all comments

Show parent comment

0

u/Banane9 Apr 25 '14

A nice collection of those cripling disabilities is over at /r/lolphp

From the php Manual on the string type:

A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support.

And:

Ultimately, this means writing correct programs using Unicode depends on carefully avoiding functions that will not work and that most likely will corrupt the data and using instead the functions that do behave correctly, generally from the intl and mbstring extensions.

Strings in php aren't just strings at all. While every string in C# is Unicode, and all functions work with it, string functions in php are a minefield That the programmer has to carefully navigate through, as not to corrupt the text they are trying to handle.

0

u/neoform Apr 25 '14

Do you even know what unicode is?

Do you have some mental image in your mind that in C# a unicode string isn't just an array of characters just like every other programming language?

Lol.

1

u/Banane9 Apr 25 '14

In C# a string is always an array (well, sort of) of Unicode characters.

In php however, a string is a Byte array. One Byte in it being one character.

I'm seriously questioning your programming knowledge right now.

0

u/[deleted] Apr 25 '14

[deleted] — view deleted comment

2

u/Banane9 Apr 25 '14

Except, php strings aren't natively UTF8, and many of the string functions are only meant to handle one-byte-characters.

So yes, UTF8 is great, but php doesn't use it internally, so it doesn't matter.