views:

174

answers:

3

Hi,

Ive got this in an XML file that i parse with JQuery.

<title>L&#229;ng</title>

I'm using .text() for pulling out the text, but it's wrong encoded.
How do I get it encoded to proper text? I want 'Lång' out of it.

Edit:

I'm using JQuery for getting data. Have it on my work computer, but something like this:

$.ajax({
 type: 'GET',
 url: 'http://myserver/blah?query_string',
 dataType: 'xml',
 success: function(data) {
   var blah = $(this).find("blahblah").text(); 
 }
});
A: 

If the characters are always encoded to numbers like that, you should be able to parse out the number, convert it to and integer with parseInt(str) then use string.fromCharCode(num) to get the character that it represents.

Freyday
A: 

You probably should just switch to utf-8. All ajax request are utf-8 by default. This might fix the problem.

naugtur
A: 

Found out how to do it! http://stackoverflow.com/questions/1219860/javascript-jquery-html-encoding

Using this function solved all enocoding problems.

function htmlDecode(value){ 
  return $('<div/>').html(value).text(); 
}
heffaklump