473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

AJAX with ASCII above 128 and below 255

hsriat
1,654 Expert 1GB
In the Database, I save some characters like £, ¥, ¼, ½, ¾.

When I display them directly in my HTML, they are fine.

But when I'm using AJAX to bring this string from PHP and display it, its displaying unknown characters (� � � � �). Rest of the string is being displayed fine, the problem is only with these characters.

How can I solve this?
Feb 22 '08 #1
10 3003
gits
5,390 Expert Mod 4TB
hi ...

it seems to be an character encoding problem with the response. i think that the XMLHttpRequest always uses UTF-8 encoding and what is the encoding of your page?

kind regards
Feb 22 '08 #2
hsriat
1,654 Expert 1GB
hi ...

it seems to be an character encoding problem with the response. i think that the XMLHttpRequest always uses UTF-8 encoding and what is the encoding of your page?

kind regards
Its UTF-8, as far as page is concerned.
But I don't think that should effect characters below ASCII 255.


And is there anything to be amended in this line?

xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
Feb 22 '08 #3
gits
5,390 Expert Mod 4TB
hmmm ... may be you could encode them at serverside as html-entities (like this)? ...
Feb 22 '08 #4
hsriat
1,654 Expert 1GB
hmmm ... may be you could encode them at serverside as html-entities (like this)? ...
No, its not working... it's converting characters like © to ©

This is actually creating problem coz I'm doing an htmlescape filter before displaying the text.

I need to do something else... Any other solution? :(
Feb 22 '08 #5
acoder
16,027 Expert Mod 8TB
And is there anything to be amended in this line?

xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
Try:
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
Feb 25 '08 #6
hsriat
1,654 Expert 1GB
Try:
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
no, thats not working.

Actually, if I add meta tag to the HTML, for charset=utf-8, it doesn't work at all.

But if I give no meta tag for charset, it works fine with such characters when they are displayed directly without using AJAX.
With AJAX, they are giving problem in both cases.

So I think, for AJAX I need to change charset=ISO-8859-1.
Feb 25 '08 #7
acoder
16,027 Expert Mod 8TB
So I think, for AJAX I need to change charset=ISO-8859-1.
That should do the trick then. Did it work?
Feb 25 '08 #8
hsriat
1,654 Expert 1GB
That should do the trick then. Did it work?
Tried both..
Expand|Select|Wrap|Line Numbers
  1. xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
  2. xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset:ISO-8859-1");
But no one worked.
Feb 29 '08 #9
hsriat
1,654 Expert 1GB
Quite an old thread, but I figured out the solution today when was working on this again.

I was using escape(), but had to use encodeURIComponent() instead.

Thank you acoder for letting me know the difference between these two in some other thread.
May 13 '08 #10
acoder
16,027 Expert Mod 8TB
Well, that's great. I don't know why I didn't think of that. Thanks for posting the solution.
May 13 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
5
by: lkrubner | last post by:
I know I'm missing something obvious, but I looked hard at this page and did not see the format of the return specified: http://us3.php.net/manual/en/function.ord.php >From the limited example...
5
by: b.stewart | last post by:
I have only been using C++ for a few afternoons and i still get confused at nearly every line i type so maybe someone here can help me. Im trying to write a small program that can change a...
11
by: Kai Bohli | last post by:
Hi all ! I need to translate a string to Ascii and return a string again. The code below dosen't work for Ascii (Superset) codes above 127. Any help are greatly appreciated. protected...
9
by: RBM007 | last post by:
Hello, I have created some pages in the (old) Atlas pages and migrated to AJAX version. After the update I noticed that any page containing ASP.NET AJAX won't compile anymore. Even if the same...
10
by: celoftis | last post by:
Using VS 2005: This morning, following the instructions here: http://ajax.asp.net/docs/overview/InstallingASPNETAJAX.aspx, I installed ASP.NET AJAX on my WinXP Pro development machine. Following...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
1
by: UKuser | last post by:
Hi, I'm trying to get my PHP scripts to email me an email which includes a button to enable a feature, which I'd like to be done via AJAX so the user can open the resulting page within their...
7
by: tommurray | last post by:
Hi all Hope someone can help with the problem I am having as it is driving me nuts! I have the below script on my site the problem lies with passing through a url parameter in the below line...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.