473,385 Members | 1,470 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,385 software developers and data experts.

AJAX in prototype.js vs ISO-8859-1

Hi,

I got 2 bugs using AJAX with ISO-8859-1:

1. While serializing form's value using prototype.js I lost accent
יאט ... because it use encodeURIComponent() function. I saw on
google, for ISO-8859-1 encoding I have to use escape(). It works fine
!

2. While receving content from AJAX Request with header <?xml
version='1.0' encoding='ISO-8859-1'?> I lost accent יאט ... only
under IE 6 it 's work fine under firefox.

What should I do ;-( ?

Best Regards,
Jean-Philippe Encausse

Oct 5 '05 #1
3 14541


Jean-Philippe Encausse wrote:

I got 2 bugs using AJAX with ISO-8859-1:

1. While serializing form's value using prototype.js I lost accent
יאט ... because it use encodeURIComponent() function. I saw on
google, for ISO-8859-1 encoding I have to use escape(). It works fine
!

2. While receving content from AJAX Request with header <?xml
version='1.0' encoding='ISO-8859-1'?> I lost accent יאט ... only
under IE 6 it 's work fine under firefox.

What should I do ;-( ?


Well learn about encodings, if you rely on code that used
encodeURIComponent then you should be aware which encoding it uses and
adapt your server side code.
And I am pretty sure that MSXML in IE can handle XML with encoding
ISO-8859-1 so if you use responseXML and that response is indeed
properly encoded then the responseXML will work fine.
If you want to use responseText however then you or anyone else on the
AJAX trip needs to be aware that MSXML as documented assumes UTF-8 by
default when building responseText, it might also detect byte order
marks for other Unicode encodings, but if will never look at the content
(e.g. in your example the XML declaration) to find out about any
encoding when building responseText.
See
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/974ceaf1-5c94-4e19-9498-a3b03df6f537.asp>

If you exchange your data as XML then you should be aware that XML
parsers are only required to support UTF-8 and UTF-16 so choosing a
different encoding in theory decreases your chances of having other apps
consume your data. In reality on the web XML parsers will probably not
have any problem with ISO-8859-1. But with MSXML you then need to ensure
that the XML parser parses the response and you use responseXML to
access the data.

If you want to use responseText then you would better send your data
UTF-8 encoded.

And if you think there are bugs in that prototype.js then contact the
author of that code.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 5 '05 #2
Well, I'm not sure to understand everything

1. I have read lots of Article about encodeURIComponent() explaining
that it doesn't correctly encode ISO-8859-1 יטא ... After some test
it doesn't work on IE or Firefox but escape() did. May be I have to
specify a specific encoding ? My page header declare ISO-8859-1 so
JavaScript inside should be aware of it ?

2. prototype.js seems to use responseText instead of responseXML and
doesn't accept change BUT I change my JSP sending XML and it's working
great !
2.1 Header is now <?xml version='1.0' encoding='UTF-8'?>
2.2 Response is now <%=
response.setContentType("text/xml;charset=UTF-8"); %> (Here is the
trick !)
Thanks,
Jean-Philippe Encausse

Oct 5 '05 #3


Jean-Philippe Encausse wrote:
1. I have read lots of Article about encodeURIComponent() explaining
that it doesn't correctly encode ISO-8859-1 יטא ... After some test
it doesn't work on IE or Firefox but escape() did. May be I have to
specify a specific encoding ? My page header declare ISO-8859-1 so
JavaScript inside should be aware of it ?


No, the function encodeURIComponent is defined in the ECMAScript
specification and that specification defines strings as a sequence of
Unicode characters and defines how encodeURIComponent works on them.
Each character that needs to be encoded is replaced by an escape
sequence of its UTF-8 representation so
encodeURIComponent('י')
always yields
%C3%A9
as the UTF-8 representation of the character י is the two-byte sequence
C3A9 (in hex code) and each byte is escaped as %DD in the URI then.

So what the function does is clearly defined and does not in any way
depend on the function being used in a browser or in script in a HTML
document or on the encoding of the script or HTML document.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: chuck | last post by:
Hi, Firstly, I don't know if this is just and isolated thing with the prototype.js library or is a problem in general with ajax calls with a '+' character, so i am posting it here. I am...
17
by: Chaprasi | last post by:
Hi I need help with prototype while doing ajax calls. So this is my JS which does a ajax calls var ajax1 = new Ajax.Request ( url, { method: 'get', parameters: params, onComplete:...
1
by: marc.fuehnen | last post by:
hi everybody, tried the framework and build a little SQL Update, triggered by a JS function: <a href="Javascript:updateData()"><img src="../images/thumbs/thumb_blue.png" border="0" /></a> ...
5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
7
by: BeeRich | last post by:
Hi folks. I built an ajax.updater reply in a website on a Mac, and she works fine. It's a simple reply, the html supplied is correct, and I also supply the target DIV as well. Just wondering...
3
by: BG Mahesh | last post by:
hi We are looking for a good Ajax library which has very good support for iframe. The ones we have considered so far are, Backbase.com - not happy with the speed Zapatech.com - it is good but...
23
by: Dautkhanov | last post by:
Hello ! Does anybody have cutted version of prototype.js with the AJAX functionality only? I am a new in prototype.js topic, so I think this task should be done by other developers. Maybe...
4
by: ext237 | last post by:
Simple ajax call seems to have some issues in Firefox. The "onComplete:" is called BEFORE the response is returned by the call. Is there a coding issue or a work around? var ajax = new...
5
RamananKalirajan
by: RamananKalirajan | last post by:
Hi those who were working in Ajax, will surely experienced with this problem. SOP - Single Origin Policy problem. I am doing a small work in Prototype Ajax. I did a sample work. When I am passing the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.