0

I know there are more questions like this that I have read but have not been able to resolve my problem. So please don't mark this as a duplicate.

So for a while now I have been getting around the question mark by using £

However I am using chart.js to create some nice looking data presentation. Now i was to change the y-axis to be in currency instead of just numbers. But to do this I have to use a function passing through the character.

scaleLabel:function(label){return  '£' + label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}

Now this causes me a problem because it shows as a question mark symbol. If i try to put & pound; in the function JavaScript just outputs it as a string.

So this leads me here, to resolve the root cause of this problem.

In my header.php file I use these meta tags

<!DOCTYPE html>
..............
<meta charset="UTF-8">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">

Why isn't my page correctly displaying the pound sign?

Alex K.
  • 171,639
  • 30
  • 264
  • 288
Matthew Smart
  • 341
  • 3
  • 16
  • In a nutshell: because you're not handling encodings correctly. Saying you've already read things on the topic, what exactly have you checked? Have you confirmed that everything is in UTF-8? Have you checked and confirmed the main applicable points in the duplicate? – deceze Feb 01 '16 at 15:37
  • try unicode point istead, like "\uNNN" – ankhzet Feb 01 '16 at 15:41
  • @MatthewSmart, in javascript strings have utf-16 internal encoding, so you must save file with that script as utf-16-encoded, or use unicode escape sequences in string (like I suggested, `...{return "\u" + label.value.toString()...` – ankhzet Feb 01 '16 at 16:12
  • @ankhzet God no. Just because Javascript ***internally*** uses UTF-16 does by no means mean that you need to serve the file as UTF-16. The encoding simply needs to match the encoding declared in the HTTP headers and/or the default expected encoding. This pretty certainly is not going to be UTF-16 under virtually any circumstances! – deceze Feb 01 '16 at 16:17
  • ... but back to the point, are you _really_ suggesting OP to change whole server encoding settings in the favor of displaying 1 (literally: _one_) symbol? – ankhzet Feb 01 '16 at 16:28
  • @ankhzet *One* symbol is likely a sign that encoding has never crossed the OP's radar before and must be properly set up once. There is no one right answer, the OP can use any encoding he feels like. But he has to decide which encoding that should be and use it appropriately throughout. That could be ISO-8859-1 for all I care. But unless he has a specific reason to use any one specific encoding (apparently probably not), UTF-8 is a perfectly sane default choice. – deceze Feb 01 '16 at 16:33
  • You don't understand what my point is... OP doesn't asked anything about wrong display of data from database, yet, suggested duplicate consists of database-related settings suggestions by approx. 90%. You suggesting to dive into server/database setting for question, asking about canvas-related unicode issues. That's just huuuuge offtopic and misleading... Besides, OP _already_ using `` etc., so yours suggestion not applicable here - thus it isn't duplicate... – ankhzet Feb 01 '16 at 16:46
  • @ankhzet OP can freely ignore parts that do not pertain to his situation (database). If you have a more narrowly fitting duplicate, by all means, post it here. The duplicate is *exhaustive* and likely covers the OPs particular problem in one of its points, so having OP check against it is a reasonable first step. – deceze Feb 01 '16 at 16:51
  • And what parts OP (whose high likely `encoding has never crossed the OP's radar before`) should ignore? Serriosly, it's like `recompile kernel`-suggestion for newbie PC user then... Also, what part of that *tl;dr* page answers OP question, specifically? I failed to find one... Answers are: `The [file with script] encoding simply needs to match the encoding declared in the HTTP headers and/or the default expected encoding.` or/and `use unicode escape sequences`. _Sights_ of first one relativelly present in suggested duplicate, and no mentions of second. Conclusion: not a duplicate, point. – ankhzet Feb 01 '16 at 17:14

0 Answers0