MCPcopy
hub / github.com/TiddlyWiki/TiddlyDesktop / escape

Function escape

source/js/utils/saving.js:86–93  ·  view source on GitHub ↗
(ch)

Source from the content-addressed store, hash-verified

84 */
85// Copied from peg.js, thanks to David Majda
86function escape(ch) {
87 var charCode = ch.charCodeAt(0);
88 if(charCode <= 0xFF) {
89 return '\\x' + pad(charCode.toString(16).toUpperCase());
90 } else {
91 return '\\u' + pad(charCode.toString(16).toUpperCase(),4);
92 }
93};
94
95// Turns a string into a legal JavaScript string
96// Copied from peg.js, thanks to David Majda

Callers

nothing calls this directly

Calls 1

padFunction · 0.85

Tested by

no test coverage detected