{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/18241","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/18241/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/18241/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/18241/events","html_url":"https://github.com/symfony/symfony/issues/18241","id":142203143,"number":18241,"title":"Fix binary check in binary dumper","user":{"login":"axel-rutz","id":15613398,"avatar_url":"https://avatars.githubusercontent.com/u/15613398?v=3","gravatar_id":"","url":"https://api.github.com/users/axel-rutz","html_url":"https://github.com/axel-rutz","followers_url":"https://api.github.com/users/axel-rutz/followers","following_url":"https://api.github.com/users/axel-rutz/following{/other_user}","gists_url":"https://api.github.com/users/axel-rutz/gists{/gist_id}","starred_url":"https://api.github.com/users/axel-rutz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axel-rutz/subscriptions","organizations_url":"https://api.github.com/users/axel-rutz/orgs","repos_url":"https://api.github.com/users/axel-rutz/repos","events_url":"https://api.github.com/users/axel-rutz/events{/privacy}","received_events_url":"https://api.github.com/users/axel-rutz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/Enhancement","name":"Enhancement","color":"02d7e1"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Yaml","name":"Yaml","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-20T20:44:06Z","updated_at":"2016-03-28T16:01:36Z","closed_at":null,"body":"In #17863 a binary check is [introduced](https://github.com/symfony/symfony/commit/79a63d50a17594e40473b9835f23d7217f090083) like\r\n`preg_match('/[^\\x09-\\x0d\\x20-\\xff]/', $value)`\r\n\r\nThis is not specific, in the sense that some invalid utf8 won't be recognized as binary.\r\n\r\nThe recognition is [nontrivial iterating a byte sequence](https://en.wikipedia.org/wiki/UTF-8#Invalid_byte_sequences), but PHP has some [simple one-liners to do it](https://stackoverflow.com/questions/6723562/how-to-detect-malformed-utf-8-string-in-php) like\r\n`$isUTF8 = preg_match('//u', $string);`"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/202459087","html_url":"https://github.com/symfony/symfony/issues/18241#issuecomment-202459087","issue_url":"https://api.github.com/repos/symfony/symfony/issues/18241","id":202459087,"user":{"login":"axel-rutz","id":15613398,"avatar_url":"https://avatars.githubusercontent.com/u/15613398?v=3","gravatar_id":"","url":"https://api.github.com/users/axel-rutz","html_url":"https://github.com/axel-rutz","followers_url":"https://api.github.com/users/axel-rutz/followers","following_url":"https://api.github.com/users/axel-rutz/following{/other_user}","gists_url":"https://api.github.com/users/axel-rutz/gists{/gist_id}","starred_url":"https://api.github.com/users/axel-rutz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axel-rutz/subscriptions","organizations_url":"https://api.github.com/users/axel-rutz/orgs","repos_url":"https://api.github.com/users/axel-rutz/repos","events_url":"https://api.github.com/users/axel-rutz/events{/privacy}","received_events_url":"https://api.github.com/users/axel-rutz/received_events","type":"User","site_admin":false},"created_at":"2016-03-28T16:01:36Z","updated_at":"2016-03-28T16:01:36Z","body":"> The thing is that the YAML dumper right now is able to also dump strings that are no UTF-8 strings (for example, the ISO-8859-1 charset used in Western Europe).\r\n\r\nI don't see how this can work in general, as you can easily construct valid ISO-8859-1 strings that are invalid as UTF-8."}}