Who has never had problems with encoding special characters? We Brazilians, using our wonderful Portuguese, may have never noticed, but the English language does not have accents in their words and, therefore, has no encoding problems we face here. The coding for the English language is "UTF-8" and we use the "ISO-8859-1", but nothing prevents we use also "UTF-8". The problem is to properly configure the system to use that encoding.
As many know, Working with Web development and coding of pages has always been hard work. Recently, I have been working with the framework prototype.js for applications with AJAX and on one page, in sending emails, characters informed num field “textarea” were sent completely wrong. Below is an example of what I'm talking about:
"Survey unprecedented in Brazil “1No Map E-Gov Municipal in Brazil”, held from September to November 2007, collaboratively and involving the voluntary participation of employees "
Following a tip from friend Antonio, the problem was solved by setting the correct settings coding.
ASP pages that generate information (in my case the XML for AJAX) and ASP pages that receive requests, simply set the options below:
Response.Charset=“UTF-8”
Session.CodePage=65001
For my case, worked perfectly!
Interesting is set in the above lines include file used by all pages. This greatly facilitates maintenance issues.
If not resolved in your case, use the parallel method for fast solution based on POG I developed below:
Js function to character encoding:
…
},
codificaString: function (){
var strRetorno="";
for(var i=0;i<arguments[0].length ;i++){
if (arguments[0].charCodeAt(i)<128){
strRetorno += arguments[0].charAt(i);
}else{
strRetorno += "&#"+arguments[0].charCodeAt(i)+";";
};
};
return strRetorno;
},
…
ASP function to decode the encoded characters by the function Js
Function HTMLDecode(sText)
Dim I
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, " ", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
*Hope you do not need to use the method POG… ?
For more information, see the links below:
Ou muiiiito util , was in trouble at the time that I returned a json asp and this post came as a glove … Thank ae, success for you
Valeu Bruno, I said too much time here, lost mt equal time Fabio that chart. Vc me salvou TB hehe.
Hugs
Brunão… I spent the day trying to solve this stop!! In the nick of time to leak.. 17:50…. I found this post!! God keep you my dear illuminating! Valeuuuuuuuuuuuuuuuuu!!!
Bruno,
Ation are worth peel.. my problem was solved.
Spoke !
buddy, After scouring the internet I came here :)
and I find myself with the same problem, or at least, very similar, see if you can give me a hand
has a pag. ISO-8859-1 and this contains a textarea that by submitting the tx sends to a page that writes to the database
and that was the way the bank will arrived in á
then kept all pages with ISO and the page that receives and records, threw Session.CodePage = 65001 without UTF, only Session.CodePage
thus worked, These accents corretos
my doubt is the reason for the error accents…
and if this would not be an exit palliative to solve a problem that may be elsewhere
thank you
[]s
Thanks for the quote. Only used a tip I found on the WEB.