Ktor: Default encoding for text/* content type should be UTF8

Created on 21 May 2017  ·  4Comments  ·  Source: ktorio/ktor

I saved code as UTF-8 (IntellJ IDEA setting.).

and I wrote the code. but, multi-byte code does not show correctly

val msg = "こんにちは世界"
call.respondText(msg, ContentType.Text.Html)
enhancement

Most helpful comment

I still think we need to default all text/* content types to UTF8, plus JSON

All 4 comments

@shinriyo content type need to have encoding specified. It's not about ktor but general requirement: charset attribute need to be specified otherwise the default encoding will be applied.

call.respondText(msg, ContentType.Text.Html.withCharset(Charsets.UTF_8))

@cy6erGn0m Thank you very much! It works!

I still think we need to default all text/* content types to UTF8, plus JSON

Fixed for any content being sent with respondText and respondWrite and not specifying any encoding.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

diaodou picture diaodou  ·  3Comments

KennethanCeyer picture KennethanCeyer  ·  4Comments

PatrickLemke picture PatrickLemke  ·  3Comments

r4zzz4k picture r4zzz4k  ·  4Comments

guenhter picture guenhter  ·  4Comments