Skip to content
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

Force UTF-8 charset on JSON responses #910

Merged
merged 1 commit into from
Jul 7, 2012

Conversation

franzliedke
Copy link
Contributor

As suggested in this forum topic, I made sure JSON responses are always sent explicitly as UTF-8 (which fixes a display bug).

The RFC says that JSON "SHOULD" be sent as UTF-8, so that makes sense.

@franzliedke
Copy link
Contributor Author

Meh.

Signed-off-by: Franz Liedke franz@develophp.org

taylorotwell added a commit that referenced this pull request Jul 7, 2012
Force UTF-8 charset on JSON responses
@taylorotwell taylorotwell merged commit dcf1966 into laravel:develop Jul 7, 2012
@darrenpowers
Copy link

I have not used jsonp much and may be miss understanding it or laravel or even the http rfc but should we not be using Config::get('application.encoding') rather than hard coding UTF-8?
What if the response needed to be in UTF-16?

@franzliedke
Copy link
Contributor Author

Citing from the aforementioned forum topic:

RFC4627 states that "JSON text SHALL be encoded in Unicode. The default encoding is UTF-8."

@darrenpowers
Copy link

Ok I get that but what if a user set their applications default to UTF-16 (still unicode) and didn't pass a charset to in the header or no header at all as is common practice with json responses. The user might expect their application default to be used just like it is elsewhere. I assume in the aforementioned RFC the default of UTF-8 should only be used if no other valid option was given and I would assume a quick check of the applications encoding would be better than dropping all the way back to one default.

zoe-edwards pushed a commit to zoe-edwards/laravel that referenced this pull request Oct 14, 2013
flap152 pushed a commit to flap152/laravel that referenced this pull request Nov 24, 2017
flap152 pushed a commit to flap152/laravel that referenced this pull request Jan 29, 2024
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.

3 participants