Last active
March 23, 2023 10:36
-
-
Save shumiyao/fe10497d851a36ce04cbc7acd8f7c8fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert unicode string to Javascript escape | |
// https://stackoverflow.com/questions/21014476/javascript-convert-unicode-string-to-javascript-escape | |
String.prototype.toUnicode = function(){ | |
var result = ""; | |
for(var i = 0; i < this.length; i++){ | |
// Assumption: all characters are < 0xffff | |
result += "\\u" + ("000" + this[i].charCodeAt(0).toString(16)).substr(-4); | |
} | |
return result; | |
}; | |
a = 'Água' // COMBINING ACUTE ACCENT (A%CC%81gua) | |
b = 'Água' // LATIN CAPITAL LETTER A WITH ACUTE | |
c = a.normalize() | |
d = b.normalize() | |
c == d | |
// true | |
a == b | |
// false | |
/// references | |
// (https://design215.com/toolbox/ascii-utf8.php)[Design215.com - South Florida Photography, Design, and Web ServicesABOUTSERVICESWORKTOOLBOXCONTACT | |
UTF-8 AND ASCII CHARACTER CHART] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment