Skip to content

If a string is not valid UTF-8, treat it as ASCII rather than giving up and serializing 'null' #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

haileys
Copy link

@haileys haileys commented Apr 3, 2012

I ran into an issue involving serializing a query string parameter as JSON. If there was a percent-encoded character above 127, json_encode would choke and simply serialize it as null.

I've changed the behaviour of json_escape_string to fall back to ASCII if its input isn't valid UTF-8. I've retained the warning it produces in this case.

@php-pulls
Copy link

Comment on behalf of laruence at php.net:

json shall be utf-8 string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants