Reputation: 85
I have to get the amount of accents of each character on a string, so I'm looping through the characters of the text of a <h2>
tag with contenteditable= true
, I can't compare some accentuated characters with the characters in the Accents DB because they get split into the character and the accent, but some other accentuated characters are treated as one character.
let Accents= {
/*...*/
'x': [
["x", 0],
["́x́", 1],
["̂x̂", 2],
["ẍ", 2],
["̌x̌", 2],
["ẋ", 1],
["̧x̧", 1], //
["̱x̱", 1],
["̣x̣", 1],
["ᶍ", 2]
],
/*...*/
}
$("button").on("click", function(){
text= $(".text").text()
for(e in text){
console.log(text[e])
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h2 class= "text" contenteditable= "true">Lorem Ipx́um ẋ</h2>
<button>Log each character</button>
How can I get x́
on the logs as with ẋ
?, I need to do this in order to compare with the characters in the Accents DB. Thanks in advance
Upvotes: 4
Views: 76