Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with special characters (åäö) in JavaScript

Status
Not open for further replies.

Pichdude

Programmer
Aug 24, 2005
66
SE
Hi,

I am having problem using special swedish charcters (åäö) in a javascript.

I have a link name stored in a database, e.g. "Överföringar". When I use it in a Javascript on my jsp-page it turns out like this: Överföringar.

I have tried using character referencs instead, but i does not help me:

If I have "Överföringar" in database it appears like "Överföringar" on jsp-page.

Any tips on how to solve this?
 
When you get it from the database - you are doing something with it to handle these swedish characters.

Maybe you are running it through a function that strips "illegal characters" or "makes the string html-safe". Either way... if you do "view-source" on the browser... and you see the word appearing as "Överföringar" then the problem is as I have described.

I doubt that Javascript is the cause if your problem here.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Use replace for all of them systematically for display.
[tt]
var s="Överföringar"; //as you get from db
var t;
t=s.replace(/Ö/g,"Ö");
t=t.replace(/ö/g,"ö");
[/tt]
This element, say, illustrates the effect.
[tt]
<a href="&#xD6;verf&#xF6;ringar">&#xD6;verf&#xF6;ringar</a>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top