react-php/react — pull request #27 by cboden (2012-05-26 00:33:53+00:00)
Title: [WIP][Socket][Http] Encoding

I should probably add a couple more unit tests before this is merged.

This is a difficult scenario to test against. To see why mbstring is required, do the following: In php.ini set the following parameters:
> mbstring.internal_encoding = UTF-8
> mbstring.func_overload = 7

And add the unit test in this PR against React's master branch (but not the rest of the code) and run phpunit. It will fail under these common ini settings.

Developers are taught to use UTF-8 for encoding, which is good. React deals a the low byte level, where Unicode and UTF-8 are not desired. Characters, such as ✓, can be stored in more than one byte of data, while being represented as a single character. In most scenarios we'd want to handle it as a single character, but in dealing with I/O we need to make sure we handle it as 3 characters. That's what this PR addresses.