Skip to content

Commit 36ff4ac

Browse files
authored
fix html escape and unescape functions (microsoft#10929)
1 parent a252e3a commit 36ff4ac

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎pxtlib/commonutil.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ namespace ts.pxtc.Util {
3030

3131
export function htmlEscape(_input: string) {
3232
if (!_input) return _input; // null, undefined, empty string test
33-
return _input.replace(/([^\w .!?\-$])/g, c => "&#" + c.charCodeAt(0) + ";");
33+
return _input.replace(/([^\w .!?\-$])/ug, c => "&#" + c.codePointAt(0) + ";");
3434
}
3535

3636
export function htmlUnescape(_input: string) {
3737
if (!_input) return _input; // null, undefined, empty string test
38-
return _input.replace(/(&#\d+;)/g, c => String.fromCharCode(Number(c.substr(2, c.length - 3))));
38+
return _input.replace(/(&#\d+;)/g, c => String.fromCodePoint(Number(c.substr(2, c.length - 3))));
3939
}
4040

4141
export function jsStringQuote(s: string) {

0 commit comments

Comments
 (0)