Created
February 18, 2013 03:55
-
-
Save myaumyau/4975024 to your computer and use it in GitHub Desktop.
[js]数値文字参照(16進数, 10進数)を文字列に変換
This file contains hidden or 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
function hexNumRefToString(hexNumRef) { | |
return hexNumRef.replace(/&#x([0-9a-f]+);/ig, function(match, $1, idx, all) { | |
return String.fromCharCode('0x' + $1); | |
}); | |
} | |
function decNumRefToString(decNumRef) { | |
return decNumRef.replace(/&#(\d+);/ig, function(match, $1, idx, all) { | |
return String.fromCharCode($1); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment