mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-30 21:46:51 +00:00
Move the editions into a subfolder
This commit is contained in:
29
editions/tw2/source/tiddlywiki/deprecated/Strings.js
Executable file
29
editions/tw2/source/tiddlywiki/deprecated/Strings.js
Executable file
@@ -0,0 +1,29 @@
|
||||
//--
|
||||
//-- Deprecated String functions
|
||||
//--
|
||||
|
||||
// @Deprecated: no direct replacement, since not used in core code
|
||||
String.prototype.toJSONString = function()
|
||||
{
|
||||
// Convert a string to it's JSON representation by encoding control characters, double quotes and backslash. See json.org
|
||||
var m = {
|
||||
'\b': '\\b',
|
||||
'\f': '\\f',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
};
|
||||
var replaceFn = function(a,b) {
|
||||
var c = m[b];
|
||||
if(c)
|
||||
return c;
|
||||
c = b.charCodeAt();
|
||||
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
|
||||
};
|
||||
if(/["\\\x00-\x1f]/.test(this))
|
||||
return '"' + this.replace(/([\x00-\x1f\\"])/g,replaceFn) + '"';
|
||||
return '"' + this + '"';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user