UNPKG

511 BJavaScriptView Raw
1import globalize from './internal/globalize';
2
3/**
4 * Similar to Javascript's in-built escape() function, but where the built-in escape()
5 * might encode unicode charaters as %uHHHH, this function will leave them as-is.
6 *
7 * NOTE: this function does not do html-escaping, see escapeHtml().
8 */
9const jsEscape = window.escape;
10
11function escape (string) {
12 return jsEscape(string).replace(/%u\w{4}/gi, function (w) {
13 return unescape(w);
14 });
15}
16
17globalize('escape', escape);
18
19export default escape;