Suppose I have a string created like this: str = '\\' + 'u00eb'. If I do document.createTextNode(str), it will give me '\u00eb', instead of ë. Dont't ask me why, but I can't define my string as str = '\u00eb'. Defining my string as str = 'ë' or 'ë' doesn't help me either. Any suggestions on how to get 'ë' printed?
Getting HTML entities into document.createTextNode
1k views Asked by Spifff At
2
There are 2 answers
0
jfriend00
On
If the data coming in looks like this:
u00eb
then, you can parse the hex string yourself:
function insertText(parent, str) {
if (str.charAt(0) == 'u') {
str = String.fromCharCode(parseInt(str.slice(1), 16));
}
parent.appendChild(document.createTextNode(str));
}
Working demo: http://jsfiddle.net/jfriend00/pk5Bp/
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in STRING
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- JSON Body is Not Passing Certain Strings
- Regex to match repeated substring in Google Sheets
- Find the sum of the numbers in the sequence
- Hello, how can I use a block parameter of withstyle parameter when we create a annotated string in jetpackpack compose
- How to convert an HTML string to an escaped one?
- Quintic Number Number Counting Hash Function
- From Buffer("string", "hex) to string JS
- Calling ToString with a nominated format returns Char rather than String
- How to update an already existing array by accessing it by a variable with the exact same name assigned to it
- Why does \b not interpreted as backslash in this regular expression
- Python: why aren’t strings being internalized if they are received from ints by using str()?
- If the element(s) in the first list equal element(s) of the second list, replace with element(s) of the third list
- About Suffix Trees features
Related Questions in ENTITIES
- how to train intent " Find average of salary of employees with following id_numbers [1,2,3,4,5,6]" with entitities?
- Problem defining DDD Aggregates and Entities
- Entities can move from one use case to another using the controller?
- Reality View: many instances of entities with attachments with different dynamic text
- Hibernate 6 NativeQuery multiple entities of same type always return first entity
- Problem making a CRUD in a Database with Symfony 7
- r - gridtext::textbox_grob: character entities and pdf
- How can I avoid repeated retrieval of data from the database in Fluent Validation?
- A-Frame entities event listener
- Dependency inversion (DIP) in clean architecture's entities
- Symfony 6 Type error in Form for getting id from another class
- How to map multiple table types to a single table without multiple FK references
- What are "Exportable" entities in Guidewire?
- Relationship between Entities with LEFT JOIN
- Symfony Getter on Class on Relation get unrelated entity
Related Questions in CREATETEXTNODE
- Dynamic drop down <option> elements from imported file
- (HTML/CSS/JS) Having trouble adding buttons to an h2 using createElement() and appendChild()
- Convert [Object text] to plain text in JavaScript
- why can't I insert text object into an element's innerHTML
- Javascrit .createTextNode output is giving errors
- Javascript, append node adds whole array instead of last element
- use variable instead of string in createTextNode()
- Adding inline tags within text node in javascript
- How do I select an element value from an Node List?
- Creating Elements no Scrolling
- DOM Manipulation: How to Create a Text Node on Button Click
- Trying to remove each line of HTML element using a newly created button
- How do I use the first child of a list with createTextNode()
- Avoiding escaping character entity references when creating a text node in XML
- Insert HTML in DOM
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
How about