Hey guys! Is there a better way to receive a UTF-8...
# ktor
b
Hey guys! Is there a better way to receive a UTF-8 String from a post request than
call.receive<ByteArray>().toString(Charsets.UTF_8)
? I'm aware that
call.receiveText()
exists but we had some encoding issues after receiving a request containing a "Fullwidth Colon" (U+FF1A).
a
Could you please post an example of the response body?
b
a
The problem is that since a client doesn't specify an encoding in the
Content-Type
header, the assumed content encoding is
Charsets.ISO_8859_1
. Here is the issue about it https://youtrack.jetbrains.com/issue/KTOR-789.
b
The issue seems pretty stale. Maybe adding a function like
call.receiveText(charset: Charset)
would be easier?
a
The fix was made today and will be available in Ktor 2.0.0. Having a
charset
parameter is a good option but the implementation isn't going be easy.
b
Thanks for the quick fix!