I am making an Electron app that has a <textarea>
.
I am using document.execCommand('insertText', false, text);
to insert text into the text area.
I want to insert the following string 'ⓐ'
however when I do this my text area displays the following: 'â“'.
How can I insert the special character with document.execCommand
?
you need to use code like this
var spchar = string.fromCharCode(???)
document.execCommand('insertText', false, spchar );
and add it to textarea
please check maybe your textarea use another font that shown your character wrong
Inside a textarea, you need to convert the following characters into their HTML entities. This is not a limit caused by electron.
You are not specifying the server side language you're using. In PHP, the correct function would be htmlspecialchars() .
As of your example, we can only tell that you're using javascript, so the JS-only solution would be to replace with the equivalent entity code:
function escapeHtml(text) {
return text
.replace(/ⓐ/g, "ⓐ")
...
}
You can find the symbol's equivalent entity code here: https://www.compart.com/en/unicode/U+24D0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.