British pound sign not displayed correctly

436 views
Skip to first unread message

Paul Drummond

unread,
Jan 22, 2009, 12:18:23 PM1/22/09
to Compojure Group
Hi all,

I feel stupid - I have a web-page generated by compojure and british pound signs (£) are displayed as weird characters, whether I use UTF-8 or not.  My unicode knowledge is worse than I thought! :(

Can anyone help?

--
Iode Software Ltd, registered in England No. 6299803.

Registered Office Address: 12 Sancroft Drive, Houghton-le-Spring, Tyne & Wear, DH5 8NE.

This message is intended only for the use of the person(s) ("the intended recipient(s)") to whom it is addressed. It may contain information which is privileged and confidential within the meaning of applicable law. If you are not the intended recipient, please contact the sender as soon as possible. The views expressed in this communication may not necessarily be the views held by The Company.

James Reeves

unread,
Jan 22, 2009, 3:58:34 PM1/22/09
to Compojure
On Jan 22, 5:18 pm, Paul Drummond <paul.drumm...@iode.co.uk> wrote:
> Hi all,
>
> I feel stupid - I have a web-page generated by compojure and british pound
> signs (£) are displayed as weird characters, whether I use UTF-8 or not.  My
> unicode knowledge is worse than I thought! :(
>
> Can anyone help?

I'll investigate. The character encoding is set to UTF-8, but maybe
there's something wrong with it.

As a work-around, is it possible for you to use the '&pound;'
character entity in your website?

- James

Paul Drummond

unread,
Jan 22, 2009, 5:17:54 PM1/22/09
to comp...@googlegroups.com
2009/1/22 James Reeves <weave...@googlemail.com>
As a work-around, is it possible for you to use the '&pound;'
character entity in your website?

Yep, &pound; works perfectly - I didn't know about it actually! 

Thanks,
Paul.



Perry Trolard

unread,
Jan 22, 2009, 6:20:25 PM1/22/09
to Compojure
Hi Paul,

This may be obvious, but are you making sure to set the Content-Type
HTTP header in your responses? Like, e.g.:

(GET "/"
[{"Content-Type" "text/html;charset=UTF-8"}
(html
[:html
[:head [:title "Testing character encoding..."]]
[:body [:p "Coöperation!"]]]))

If this isn't set, it's possible that your browser is using its
default encoding, which very well might not be UTF-8.

Best,
Perry

Paul Drummond

unread,
Jan 23, 2009, 6:01:07 AM1/23/09
to comp...@googlegroups.com
2009/1/22 Perry Trolard <tro...@gmail.com>

This may be obvious, but are you making sure to set the Content-Type
HTTP header in your responses?

Yes, I tried various values for the charset as well.  If I use the standard ISO value (ISO-8859-1 I believe) the pound sign is displayed as weird characters and if I change it to UTF-8, I get a different set of weird characters!
 
it's possible that your browser is using its
default encoding, which very well might not be UTF-8.


I use Firefox and have never changed the encoding.  I've just checked and it is set to UTF-8.

When I experiment at the REPL I get the following behaviour:

user=> (html "$")
"$"
user=> (html "%")
"%"
user=> (html "~")
"~"
user=> (html "£")
"��"
user=>

I am using google mail to write this and it has converted the REPL output for the pound sign to two dimonds with question marks in them.  The actual  repl ouput for the pound sign is a unicode string - backslash 357 backslash 277 and so on....

Strange if you ask me...
Reply all
Reply to author
Forward
0 new messages