Hi I need some help. I am posting unicode character in the AJAX request. I am writing following code:- var pars ''cmd=contact.view&mode=getContactData&name=''+encodeURIComponent(''moñ''); var myAjax = new Ajax.Request( url, { method: ''post'', parameters: pars, onComplete: processFunction }); now here a special character exists i.e ñ. The problem is that when Ajax request is posted, the ñ character automatically get converted to ñ (on server side) which gives some wrong result in my server side function. I am very surprised that how the ñ automatically get converted to ñ. Please help me in this matter Harpreet --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Probably this is a mismatch of the character set used in your page, in the request, and/or on your server. As I understand it, by default HTTP requests use ISO-8859-1, not Unicode. [1] ISO-8859-1 (aka "latin1") correctly allows for the ''ñ'' ("enya") [2] and so provided you''re sending the correct character (it''s a single eight-bit value), you should be fine. I''d check the encoding of the page itself, check to see whether the server is applying some other character set instead of ISO-8859-1 (which it shouldn''t be unless you''re specifying the charset header in the request), etc., etc. [1] http://tools.ietf.org/html/rfc2616#page-21 [2] http://en.wikipedia.org/wiki/ISO/IEC_8859-1 FWIW... -- T.J. Crowder tj / crowder software / com On Jun 3, 10:12 am, Harpreet <harpreetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi > > I need some help. I am posting unicode character in the AJAX request. > I am writing following code:- > > var pars > ''cmd=contact.view&mode=getContactData&name=''+encodeURIComponent(''moñ''); > var myAjax = new Ajax.Request( > url, > { > method: ''post'', > parameters: pars, > onComplete: processFunction > }); > > now here a special character exists i.e ñ. The problem is that when > Ajax request is posted, the ñ character automatically get converted to > ñ (on server side) which gives some wrong result in my server side > function. > > I am very surprised that how the ñ automatically get converted to ñ. > > Please help me in this matter > > Harpreet--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Right. Just for a little extra background, ISO-8859-1 and UTF-8 (the 8-bit encoding for Unicode) both allow the ñ character, but they encode it differently. If the server is receiving the two byte ñ version, your page is probably sending UTF-8, and the server is interpreting it as 8859. Both sides of the conversation need to be speaking the same encoding. -Fred On Tue, Jun 3, 2008 at 5:06 AM, T.J. Crowder <tjcrowder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > Probably this is a mismatch of the character set used in your page, in > the request, and/or on your server. As I understand it, by default > HTTP requests use ISO-8859-1, not Unicode. [1] ISO-8859-1 (aka > "latin1") correctly allows for the ''ñ'' ("enya") [2] and so provided > you''re sending the correct character (it''s a single eight-bit value), > you should be fine. I''d check the encoding of the page itself, check > to see whether the server is applying some other character set instead > of ISO-8859-1 (which it shouldn''t be unless you''re specifying the > charset header in the request), etc., etc. > > [1] http://tools.ietf.org/html/rfc2616#page-21 > [2] http://en.wikipedia.org/wiki/ISO/IEC_8859-1 > > FWIW... > -- > T.J. Crowder > tj / crowder software / com > > On Jun 3, 10:12 am, Harpreet <harpreetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi > > > > I need some help. I am posting unicode character in the AJAX request. > > I am writing following code:- > > > > var pars > > ''cmd=contact.view&mode=getContactData&name=''+encodeURIComponent(''moñ''); > > var myAjax = new Ajax.Request( > > url, > > { > > method: ''post'', > > parameters: pars, > > onComplete: processFunction > > }); > > > > now here a special character exists i.e ñ. The problem is that when > > Ajax request is posted, the ñ character automatically get converted to > > ñ (on server side) which gives some wrong result in my server side > > function. > > > > I am very surprised that how the ñ automatically get converted to ñ. > > > > Please help me in this matter > > > > Harpreet >-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Mr T.J. Crowder Thanks for your reply and all the help. Well I have checked the Prototype Js file code and found the :- Ajax.Base = Class.create({ initialize: function(options) { this.options = { method: ''post'', asynchronous: true, contentType: ''application/x-www-form-urlencoded'', encoding: ''UTF-8'', parameters: '''', evalJSON: true, evalJS: true }; Here the Ajax options are being set and we can see that encoding is given UTF-8. Now what should I put in the encoding parameter instead of UTF-8 which allows the character like ''ñ''. I have tried the ISO-8859, but the result is same. Anu guidance here will be great help. Thanks again Harpreet On Jun 3, 3:06 pm, "T.J. Crowder" <tjcrow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Probably this is a mismatch of the character set used in your page, in > the request, and/or on your server. As I understand it, by default > HTTP requests use ISO-8859-1, not Unicode. [1] ISO-8859-1 (aka > "latin1") correctly allows for the ''ñ'' ("enya") [2] and so provided > you''re sending the correct character (it''s a single eight-bit value), > you should be fine. I''d check the encoding of the page itself, check > to see whether the server is applying some other character set instead > of ISO-8859-1 (which it shouldn''t be unless you''re specifying the > charset header in the request), etc., etc. > > [1]http://tools.ietf.org/html/rfc2616#page-21 > [2]http://en.wikipedia.org/wiki/ISO/IEC_8859-1 > > FWIW... > -- > T.J. Crowder > tj / crowder software / com > > On Jun 3, 10:12 am, Harpreet <harpreetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi > > > I need some help. I am posting unicode character in the AJAX request. > > I am writing following code:- > > > var pars > > ''cmd=contact.view&mode=getContactData&name=''+encodeURIComponent(''moñ''); > > var myAjax = new Ajax.Request( > > url, > > { > > method: ''post'', > > parameters: pars, > > onComplete: processFunction > > }); > > > now here a special character exists i.e ñ. The problem is that when > > Ajax request is posted, the ñ character automatically get converted to > > ñ (on server side) which gives some wrong result in my server side > > function. > > > I am very surprised that how the ñ automatically get converted to ñ. > > > Please help me in this matter > > > Harpreet- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
What software are you using on the server side? How is your server configured? Where are you seeing the bad character, in a response page, in a file, in the database? A little snippet of server code that''s giving the wrong result would help. -Fred On Tue, Jun 3, 2008 at 5:39 AM, Harpreet <harpreetlove-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Here the Ajax options are being set and we can see that encoding is > given UTF-8. > Now what should I put in the encoding parameter instead of UTF-8 which > allows the character like ''ñ''. > I have tried the ISO-8859, but the result is same. > > Anu guidance here will be great help.-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Fred I am using PHP on the server side. I need to do searching for the some records who starts with moñ. So I simply writing an SQl query and adding following filter in it ///Match First Name/// if($_POST["FirstName"]!="") { $filters .=" AND ".DB_TABLE_CONTACTS_REPS.".FirstName like ''%".trim(urldecode($_POST[''FirstName'']))."%''"; } Here I am sending moñ in first name parameter through POST via AJAX using Prototype.js. When I am prining the query (using document.write), I am getting the following ''FirstName like ''%moñ%''. And it is returning wrong results. And Fred when I use the simple AJAX code without using the Prototype js, I am getting correct result. So something needs to be changed in Prototype.js. I hope this will give you some idea Thanks again Harpreet On Jun 3, 3:48 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> What software are you using on the server side? How is your server > configured? Where are you seeing the bad character, in a response page, in > a file, in the database? A little snippet of server code that''s giving the > wrong result would help. > > -Fred > > On Tue, Jun 3, 2008 at 5:39 AM, Harpreet <harpreetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Here the Ajax options are being set and we can see that encoding is > > given UTF-8. > > Now what should I put in the encoding parameter instead of UTF-8 which > > allows the character like ''ñ''. > > I have tried the ISO-8859, but the result is same. > > > Anu guidance here will be great help. > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
That smells to me like your server is talking ISO-8859-1, you have no charset header in your pages, which makes your browser default to 8859 as well, and so Prototype is breaking it because it''s telling the server it''s sending UTF-8 when it really isn''t. If you''re saying it works fine without Prototype, try explicitly suppressing the charset header in Prototype by putting encoding: null in your options hash to Ajax.Request. On Tue, Jun 3, 2008 at 6:51 AM, Harpreet <harpreetlove-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > And Fred when I use the simple AJAX code without using the Prototype > js, I am getting correct result.-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Fred for all your help Actually I was checking on my local system which was windows based, character was appearing fine. The problem is now solved in the Linux system as well I need to change some settings in apache httpd.conf configuraiton. It is due to the server not being set to server pages as UT-8 So problem was on server end, not the prototype js. Thanks again Harpreet On Jun 3, 6:08 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> That smells to me like your server is talking ISO-8859-1, you have no > charset header in your pages, which makes your browser default to 8859 as > well, and so Prototype is breaking it because it''s telling the server it''s > sending UTF-8 when it really isn''t. If you''re saying it works fine without > Prototype, try explicitly suppressing the charset header in Prototype by > putting encoding: null in your options hash to Ajax.Request. > > On Tue, Jun 3, 2008 at 6:51 AM, Harpreet <harpreetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > And Fred when I use the simple AJAX code without using the Prototype > > js, I am getting correct result. > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---