javascript - Value &# to unicode convert -
i have lots of characters in form ¶
display unicode characters in text editor. ought convert them:
var newtext = doctext.replace( /&#(\d+);/g, string.fromcharcode(parseint("$1", 10)) );
but doesn't seem work. regular expression /&#(\d+);/
getting me numbers out -- string.fromcharcode
not appear give results i'd like. up?
the replacement part should anonymous function instead of expression:
var newtext = doctext.replace( /&#(\d+);/g, function($0, $1) { return string.fromcharcode(parseint($1, 10)); } );
Comments
Post a Comment