JQuery inserting unicode instead of character

I am looking for a way to make really basic wysiwyg, for example, when the user licks a button, he inserts a β™‚ ( ♂)

It works, but there are two problems: 1 - Only Unicode characters are inserted, they are not converted to a character ( ♂)

2- If you have time, is there an easy way to insert a character, where is the "text cursor", and not at the end of the contents of the text field?

thanks for the help

http://jsfiddle.net/cdjEr/3/

+7
source share
1 answer

♂ is HTML code.
It is processed only in the HTML source.

Javascript string literals use their own escape code: '\u2642' (with a code point in hex rather than decimal).
You can also just use the character directly: 'β™‚' . (for this it is necessary that you set the file encodings correctly)

+10
source

All Articles