Yes, you can return a full response map with the desired encoding:
(GET "/" []
{:status 200
:headers {"Content-Type" "text/html; charset=ISO-8859-1"}
:body "Hello World"})
Or use the ring.util.response namespace:
(GET "/" []
(-> (resp/response "Hello World")
(resp/charset "ISO-8859-1")))
Or write some middleware to change the charset globally:
(defn text-response? [response]
(some-> (resp/get-header response "Content-Type")
(.startsWith "text/")))
(defn wrap-charset [handler charset]
(fn [request]
(let [response (handler request)]
(if (text-response? response)
(resp/charset response "ISO-8859-1")
response))))
However, it's odd that you "can't consume UTF-8 encoding". Are you sure
that's the problem?
- James
On 24 June 2015 at 14:47, Jonathon McKitrick <[email protected]> wrote:
> I have a web app that apparently cannot consume UTF-8 encoding. Can
> compojure generate responses in latin-1 encoding?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.