Match PHP5 handling of invalid multibyte sequences in htmlentities()

Summary: PHP 5 will skip multiple bytes in some cases when it encounters an invalid byte
in a multibyte sequence.

Fixes #3583

{sync, type="child", parent="internal", parentrevid="1696516", parentrevfbid="1520912944847080", parentdiffid="5819025"}

Reviewed By: @fredemmott

Differential Revision: D1696516

Signature: t1:1696516:1417551745:4e56c4ce4e017c2815a66e55bd082f0d982403c7