Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special symbols on HTML5 canvas

Tags:

html

ascii

canvas

I want to draw special ASCII symbols on my HTML5 canvas i.e. £ but they actually show up as the letters themselves rather than a pound symbol. What can I do to make these show up correctly?

like image 645
Chris Avatar asked Oct 26 '25 08:10

Chris


1 Answers

£ is a HTML entity, it doesn't mean anything apart in XML/SGML based markup languages.

But you don't need it as Javascript lets you manage Unicode. Simply use the literal

var pound = '£';

and be sure to save and serve your javascript files as UTF-8.

Or if you can't use UTF-8, escape it as

var pound = "\u00A3";
like image 180
Denys Séguret Avatar answered Oct 28 '25 02:10

Denys Séguret