473,698 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 encodeURICompon ent() 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 14561


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 encodeURICompon ent() 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
encodeURICompon ent 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.as p>

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 encodeURICompon ent() 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.setCon tentType("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 encodeURICompon ent() 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 encodeURICompon ent is defined in the ECMAScript
specification and that specification defines strings as a sequence of
Unicode characters and defines how encodeURICompon ent works on them.
Each character that needs to be encoded is replaced by an escape
sequence of its UTF-8 representation so
encodeURICompon ent('é')
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
4653
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 trying to send input from a form to do a live php boolean search. so an example search string is
17
3294
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: showResults, onFailure: showFailure
1
3168
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> <div id="yeah">
5
20071
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 with Firefox,but with IE6 the onFailure never gets called and the request never completes. My code: var ajaxReq = new Ajax.Request( url, {method: 'post', parameters:
31
3136
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 around here? If so, do you know if Ajax.NET can be used without prototype.js? -- "The most convoluted explanation that fits all of the made-up facts is the most likely to be believed by conspiracy theorists. Fitting the
7
1817
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 why a PC won't show anything. Cheers
3
2770
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 doesn't have support for iframe openreco.org - it is good but doesn't support iframe Any pointers is appreciated. We are doing the development on Linux.
23
1759
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 protorype.js should be splitted into small pieces of the js scripts with groupped functionality
4
7704
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 Ajax.Request( url, {method: 'post', parameters: params, onComplete: evalInfo }); function evalInfo( request ) { // do stuff with request
5
2521
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 URL to the Ajax call within the same directory. It is showing an exception "Access Denied". The cause for this exception is SOP. This occur only with the IE. Had anyone overcome this problem. If so means pls tell me that would be very helpful for...
0
8671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.