[OpenLayers-Users] encoding international characters
Duarte Carreira
DCarreira at edia.pt
Mon Apr 23 18:18:59 EDT 2007
Problem solved.
Setting everything to utf-8 didn't work so I tried iso-8859-1.
I added http-equiv tags to my html:
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"/>
and to all asp's I added:
Response.Charset = "ISO-8859-1"
Response.AddHeader "Content-Type","text/html; charset=iso-8859-1"
And on my ajax requests I escaped all parameters.
At first nothing worked. It seemed IIS got values that still needed to be
decoded. I tried all decoding functions at
http://andrewu.co.uk/tools/uriencoder/ and spotted the one that worked.
The one thing that got everything working was the fake function
encodeURIComponent(). Even non-Ajax requests, like WMS requests. So my guess
is somewhere in Ajax.js and on WMS/HTTPRequest code, an extra encoding was
occurring.
For now, all is well... but I wonder what lurks waiting for the next time...
For instance, OpenLayers.parseXMLString encodes to utf-8 no matter what the
page or the server is using... I don't know enough about this but it seems
it shouldn't?
Again, Christopher, thank you!
Duarte
Duarte Carreira wrote:
>
> Christopher,
>
> Thanks for your tip.
>
> Yes, I am now trying to find the correct settings for character
> set/encoding.
>
> In the html page I can set the html lang attribute, and also the
> http-equiv charset tag.
> Then in the asp that I call through ol, I can set the response.charset
> attribute.
> There is another asp I call through ajax, and here I can also set the
> response.charset.
>
> I seem to not be able to set all pages to the same setting to get correct
> display on all fronts.
>
> I'll try your tip and reply with the results.
>
> Thanks again.
> Duarte
>
>
>
> Christopher Schmidt-4 wrote:
>>
>> On Sun, Apr 22, 2007 at 05:03:11AM -0700, Duarte Carreira wrote:
>>> For instance "ALC??CER" should encode to "ALC%C1CER", that's what the
>>> browser
>>> does if I write the query in the address box.
>>
>> I have a feeling the difference here is related to character sets: the
>> character you've just described should be encoded that way if it is in
>> iso-8859-1, but not in UTF-8. It seems that the 'encodeURIComponent'
>> Javascript function which is used (a Javascript builtin) is converting
>> this to utf-8. It's not clear to me whether this is the 'right' thing or
>> not, but it is certainly causing you problems.
>>
>> A workaround is to override the encodeURIComponent functino by placing
>> this as the first line of your init():
>>
>> encodeURIComponent = function(data) { return data; }
>>
>> This will override the Javascript builtin, and cause OpenLayers to not
>> encode your data. I can't speak to whether this is the 'right' thing to
>> do, but it will let you move forward with the application.
>>
>> Regards,
>> --
>> Christopher Schmidt
>> MetaCarta
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>
>
--
View this message in context: http://www.nabble.com/encoding-international-characters-tf3626355.html#a10150418
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list