I need to extract the HTML substring with JS, which is position dependent. I store special characters HTML-encoded.
For example:
HTML
<div id="test"><p>lösen & grüßen</p></div>​
Text
lösen & grüßen
My problem is in the JS part, for example, when I try to extract a lö fragment that has a starting position depending on HTML, 3 and ending position 9 inside the <div> block. It seems that JS converts some special characters inside, so a counter from 3 to 9 mistakenly interpreted as " lösen " and not " lö ". Other special characters, such as & do not affect this.
So my question is: if someone knows why JS behaves this way? Characters like ä or ö are converted, and characters like & or are equal. Is there any way to avoid this conversion?
I created a fiddle to demonstrate this: JSFiddle
Thanks for any help!
EDIT:
Perhaps I explained this a bit confusing, sorry for that. I want HTML:
<p>lösen & grüßen</p> <p>lösen & grüßen</p> .
Each special character must be uncured, except for HTML tags. Like in the HTML above.
But JS will automatically convert ö or ü in ö or ü what I need to avoid.
noplacetoh1de
source share