I was surprised to find my ring app was not serving utf-8 properly. I pared this down to a simple test case, does anyone know how to ensure that this will always return utf-8 to the browser?
(ns utf8test.core)
(defn app
[request]
{:status 200 :body "ɮѪϴ"})
In project.clj (using the lein-ring plugin):
:ring {:handler utf8test.core/app}
In terminal:
> lein ring server
---> ɮѪϴ (this is wrong, should be ɮѪϴ)
Preferably a method that works for tomcat as well, since this is where the app is being deployed.
Thanks!
Without setting a Content-Type
header, Jetty is probably sending a response indicating the platform-default encoding. Try using the content-type
or charset
response functions to add an appropriate header (e.g. (charset {:status 200 :body "..."} "UTF-8")
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With