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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.