3

I need to dynamically append a text to a <div> with JavaScript. This text is retrieved from a database and it also contains special character as ü or '. Now i'm using the createTextNode() but the HTML special characters like &xxxx; aren't "resolved" then the output isn't correct.

Is there any method to print out the text with special character displayed correctly?

Thanks for any reply

1
  • 1
    Use JavaScript notation for the special characters instead of HTML notation. Commented Sep 8, 2015 at 19:11

2 Answers 2

4

I think it will do exactly what you want if you use innerHTML instead of createTextNode().

Sign up to request clarification or add additional context in comments.

Comments

1

For ü you will have to use \xfc

<div id="result"></div>
$('#result').text('\xfc');

Here is working example: http://jsfiddle.net/djnnvc7m/

And here is the symbol table. Refer to 'HEX' column in table. http://www.ascii.cl/htmlcodes.htm

1 Comment

Or simply 'ü'? Just make sure to transfer the script (or whatever it is) with the matching encoding and it'll work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.