Change media_type of JSONResponse to "application/json; charset=utf-8" #2340
-
I am using fastapi (which using starlette), and when I return data with Korean character (and possibly none-alphabet character), encoding is wrong. It is double-encoded: it was encoded in UTF-8, then the resulting bytes were interpreted as ISO-8859-1 (or a similar encoding) and encoded in UTF-8 again. (answer from GitHub copilot) example: "피노키오랩" expected to be encoded to %ED%94%BC%EB%85%B8%ED%82%A4%EC%98%A4%EB%9E%A9 (in url encoded form), but resulted in %C3%AD%C2%94%C2%BC%C3%AB%C2%85%C2%B8%C3%AD%C2%82%C2%A4%C3%AC%C2%98%C2%A4%C3%AB%C2%9E%C2%A9 And when I change media_type of JSONResponse to "application/json; charset=utf-8", this issue solved |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Can you share a MRE with an application and client code? |
Beta Was this translation helpful? Give feedback.
-
I did an investigation about this. The |
Beta Was this translation helpful? Give feedback.
I did an investigation about this.
The
charset=utf-8
is redundant, becauseapplication/json
can only becharset=utf-8
.