views:

48

answers:

4

Problem with Unicode in asp

These two address are created using the same function from a single DB entry the only diff that I can see is that the top is written to the page directly the bottom is written via JS in an Iframe to the parent page

this is was the classic ASP outputs and it is wrong

Fxxxx Ã…sbrink
RSG connexion AB
Baggängsvägen 18
1245 Karlskoga
Karlskoga
123345
Sweden
+1233514543 

this is what the JS code outputs to the page do show how it should show

Fxxxx Åsbrink
RSG connexion AB
Baggängsvägen 18
1224 Karlskoga
Karlskoga
12345
Sweden
+1233514543 

I have set the page to utf-8 set the codepage to 65001 and am still getting what look 2 letters where I should be getting 1

Any idea how to fix this?

A: 

HTML Encode the characters as it should be.

TomTom
no tried that it just escaped the string
Pbearne
A: 

Javascript should handle UTF8 just fine, so can you show us a snippet of the JS code to make sure there isn't a unicode error there?

http://www.joelonsoftware.com/articles/Unicode.html

Michael Pryor
yes the JS code is working and it outputs the bottom address block what I can't work out why the straight classic ASP is shown 2 leters
Pbearne
+1  A: 

This is classic. You're most likely not setting Response.Charset = "UTF-8", together with Response.CodePage = 65001.

thomask
no think I have set the response.codepage to utf-8 I will try this and report back
Pbearne
You need both. Also if your pages contain <meta http-equiv="Content-Type" content="text/html; xxx"> with the wrong charset, the browser will interpret the pages incorrectly.
thomask
A: 

I tracked it down to Response.CodePage = 65001 being set in an an include of an include the page worked just fine once I removed it.

So if you have problem like this remove all extra code and starting code back.

Paul

Pbearne