0

Hello,

I'm having some trouble with a £ sign, it's being displayed to the user as the <?> question-mark-in-a-black-diamond icon.

I have an SQL Server database with a £ in a table. (Collation Latin_General_C1_AS which is analoguous to 8859-1)

I have a PHP script which retreives this record without issue and can display it on a web page OK. This is with the PHP script file's encoding set to UTF-8 without BOM.

The issue appears to be displaying the page in an AJAX request.

var http = new XMLHttpRequest;
...
    document.getElementById('myDivElement').innerHTML = http.responseText;

http.responseText appears to be treating the results of the response text as plain old binary ascii and therefore loosing the £ character.

I'm sure this has to be a common issue as JS/AJAX is everywhere now and £ signs are kind of common in the United Kingdom (usually coloured in red and preceded by a - sign if my online banking is anything to go by)

I must be overtired/undercaffeined or something because I have tried and failed to work the Google machine to find the answer.

What is the usual resolution to displaying a £ sign through an AJAX request please?

Thanks
Ben

2
Contributors
2
Replies
13
Views
3 Years
Discussion Span
Last Post by BenWard
1

hi BenWard ,

i dont know exact solution for your problem but try with this

pls replace this £ symbol with '&pound' word at php side and send these results to your webpage through AJAX as it is it will produce the currency symbol as you expected

i am not sure but its work fine

let me know the status

have a great day

go through this URL it gives better clarification

http://webdesign.about.com/od/localization/l/blhtmlcodes-cur.htm

note : comments are appreciated

Edited by radhakrishna.p: to give better clarity

0

Thanks this does work.

I have taken it a step further and used the PHP htmlentities() function so it will cater for other characters as well if they come up.

It still looks like a strange issue to me as JavaScript supposedly uses UTF-16 for strings which shouldn't have any trouble at all with £ signs so I'm none the wiser as to where exactly the issue is occurring and that bothers me!

Thanks for your help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.