ilib-tools-common 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/EscaperFactory.js +13 -2
- package/lib/EscaperFactory.js.map +1 -1
- package/lib/escapes/CppEscaper.js +48 -0
- package/lib/escapes/CppEscaper.js.map +1 -0
- package/lib/escapes/EscapeCommon.js +49 -3
- package/lib/escapes/EscapeCommon.js.map +1 -1
- package/lib/escapes/ScalaEscaper.js +43 -0
- package/lib/escapes/ScalaEscaper.js.map +1 -0
- package/package.json +1 -1
- package/src/EscaperFactory.js +30 -0
- package/src/escapes/CppEscaper.js +100 -0
- package/src/escapes/EscapeCommon.js +315 -0
- package/src/escapes/ScalaEscaper.js +95 -0
package/lib/EscaperFactory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _CSharpEscaper=_interopRequireDefault(require("./escapes/CSharpEscaper.js"));var _JavaEscaper=_interopRequireDefault(require("./escapes/JavaEscaper.js"));var _JavascriptEscaper=_interopRequireDefault(require("./escapes/JavascriptEscaper.js"));var _JsonEscaper=_interopRequireDefault(require("./escapes/JsonEscaper.js"));var _RegexBasedEscaper=_interopRequireDefault(require("./escapes/RegexBasedEscaper.js"));var _PHPEscaper=_interopRequireDefault(require("./escapes/PHPEscaper.js"));var _SmartyEscaper=_interopRequireDefault(require("./escapes/SmartyEscaper.js"));var _PythonEscaper=_interopRequireDefault(require("./escapes/PythonEscaper.js"));var _SwiftEscaper=_interopRequireDefault(require("./escapes/SwiftEscaper.js"));var _URIEscaper=_interopRequireDefault(require("./escapes/URIEscaper.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}/*
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _CppEscaper=_interopRequireDefault(require("./escapes/CppEscaper.js"));var _CSharpEscaper=_interopRequireDefault(require("./escapes/CSharpEscaper.js"));var _JavaEscaper=_interopRequireDefault(require("./escapes/JavaEscaper.js"));var _JavascriptEscaper=_interopRequireDefault(require("./escapes/JavascriptEscaper.js"));var _JsonEscaper=_interopRequireDefault(require("./escapes/JsonEscaper.js"));var _RegexBasedEscaper=_interopRequireDefault(require("./escapes/RegexBasedEscaper.js"));var _PHPEscaper=_interopRequireDefault(require("./escapes/PHPEscaper.js"));var _ScalaEscaper=_interopRequireDefault(require("./escapes/ScalaEscaper.js"));var _SmartyEscaper=_interopRequireDefault(require("./escapes/SmartyEscaper.js"));var _PythonEscaper=_interopRequireDefault(require("./escapes/PythonEscaper.js"));var _SwiftEscaper=_interopRequireDefault(require("./escapes/SwiftEscaper.js"));var _URIEscaper=_interopRequireDefault(require("./escapes/URIEscaper.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}/*
|
|
2
2
|
* EscaperFactory.js - factory function that returns escaper instances
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2025 JEDLSoft
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
* Return an Escaper instance for the given style. The style must be one of the
|
|
20
20
|
* following:
|
|
21
21
|
* <ul>
|
|
22
|
+
* <li>cpp - escape for C++ regular strings</li>
|
|
23
|
+
* <li>cpp-char - escape for C++ character literals</li>
|
|
24
|
+
* <li>cpp-raw - escape for C++ raw strings</li>
|
|
25
|
+
* <li>cpp-wide - escape for C++ wide strings</li>
|
|
26
|
+
* <li>cpp-utf8 - escape for C++ UTF-8 strings</li>
|
|
27
|
+
* <li>cpp-utf16 - escape for C++ UTF-16 strings</li>
|
|
28
|
+
* <li>cpp-utf32 - escape for C++ UTF-32 strings</li>
|
|
22
29
|
* <li>csharp - escape for C#</li>
|
|
23
30
|
* <li>csharp-raw - escape for C# raw strings</li>
|
|
24
31
|
* <li>csharp-verbatim - escape for C# verbatim strings</li>
|
|
@@ -39,6 +46,10 @@
|
|
|
39
46
|
* <li>python-byte - escape for Python byte strings</li>
|
|
40
47
|
* <li>python-multi - escape for Python multi-line strings</li>
|
|
41
48
|
* <li>regexp - escape for regular expressions</li>
|
|
49
|
+
* <li>scala - escape for Scala regular strings</li>
|
|
50
|
+
* <li>scala-raw - escape for Scala raw strings</li>
|
|
51
|
+
* <li>scala-triple - escape for Scala triple-quoted strings</li>
|
|
52
|
+
* <li>scala-char - escape for Scala character literals</li>
|
|
42
53
|
* <li>smarty - escape for Smarty templates (default, same as smarty-double)</li>
|
|
43
54
|
* <li>smarty-double - escape for double-quoted Smarty strings</li>
|
|
44
55
|
* <li>smarty-single - escape for single-quoted Smarty strings</li>
|
|
@@ -52,6 +63,6 @@
|
|
|
52
63
|
* @param {string} style the style to use to determine how to escape
|
|
53
64
|
* @returns {Escaper} a new Escaper instance, or undefined if the style
|
|
54
65
|
* is not recognized
|
|
55
|
-
*/function escaperFactory(style){if(style==="html"){style="xml"}if(escaperCache[style]){return escaperCache[style]}switch(style){case"csharp":case"c#":case"csharp-raw":case"c#-raw":case"csharp-verbatim":case"c#-verbatim":escaperCache[style]=new _CSharpEscaper["default"](style);break;case"kotlin":case"kotlin-raw":case"java":case"java-raw":escaperCache[style]=new _JavaEscaper["default"](style);break;case"json":escaperCache[style]=new _JsonEscaper["default"];break;case"js":case"js-template":case"javascript":case"javascript-template":escaperCache[style]=new _JavascriptEscaper["default"](style);break;case"php":case"php-double":case"php-single":case"php-heredoc":case"php-nowdoc":escaperCache[style]=new _PHPEscaper["default"](style);break;case"smarty":case"smarty-double":case"smarty-single":escaperCache[style]=new _SmartyEscaper["default"](style);break;case"python":case"python-raw":case"python-byte":case"python-multi":escaperCache[style]=new _PythonEscaper["default"](style);break;case"swift":case"swift-multi":case"swift-extended":escaperCache[style]=new _SwiftEscaper["default"](style);break;case"uri":case"url":escaperCache[style]=new _URIEscaper["default"](style);break;default:try{escaperCache[style]=new _RegexBasedEscaper["default"](style)}catch(e){// if the style is not recognized, just return undefined
|
|
66
|
+
*/function escaperFactory(style){if(style==="html"){style="xml"}if(escaperCache[style]){return escaperCache[style]}switch(style){case"cpp":case"cpp-char":case"cpp-raw":case"cpp-wide":case"cpp-utf8":case"cpp-utf16":case"cpp-utf32":escaperCache[style]=new _CppEscaper["default"](style);break;case"csharp":case"c#":case"csharp-raw":case"c#-raw":case"csharp-verbatim":case"c#-verbatim":escaperCache[style]=new _CSharpEscaper["default"](style);break;case"kotlin":case"kotlin-raw":case"java":case"java-raw":escaperCache[style]=new _JavaEscaper["default"](style);break;case"json":escaperCache[style]=new _JsonEscaper["default"];break;case"js":case"js-template":case"javascript":case"javascript-template":escaperCache[style]=new _JavascriptEscaper["default"](style);break;case"php":case"php-double":case"php-single":case"php-heredoc":case"php-nowdoc":escaperCache[style]=new _PHPEscaper["default"](style);break;case"scala":case"scala-raw":case"scala-triple":case"scala-char":escaperCache[style]=new _ScalaEscaper["default"](style);break;case"smarty":case"smarty-double":case"smarty-single":escaperCache[style]=new _SmartyEscaper["default"](style);break;case"python":case"python-raw":case"python-byte":case"python-multi":escaperCache[style]=new _PythonEscaper["default"](style);break;case"swift":case"swift-multi":case"swift-extended":escaperCache[style]=new _SwiftEscaper["default"](style);break;case"uri":case"url":escaperCache[style]=new _URIEscaper["default"](style);break;default:try{escaperCache[style]=new _RegexBasedEscaper["default"](style)}catch(e){// if the style is not recognized, just return undefined
|
|
56
67
|
return undefined}break}return escaperCache[style]}var _default=exports["default"]=escaperFactory;module.exports=exports.default;
|
|
57
68
|
//# sourceMappingURL=EscaperFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EscaperFactory.js","names":["_CSharpEscaper","_interopRequireDefault","require","_JavaEscaper","_JavascriptEscaper","_JsonEscaper","_RegexBasedEscaper","_PHPEscaper","_SmartyEscaper","_PythonEscaper","_SwiftEscaper","_URIEscaper","e","__esModule","escaperCache","escaperFactory","style","CSharpEscaper","JavaEscaper","JsonEscaper","JavascriptEscaper","PHPEscaper","SmartyEscaper","PythonEscaper","SwiftEscaper","URIEscaper","RegexBasedEscaper","undefined","_default","exports","module","default"],"sources":["../src/EscaperFactory.js"],"sourcesContent":["/*\n * EscaperFactory.js - factory function that returns escaper instances\n *\n * Copyright © 2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport CSharpEscaper from \"./escapes/CSharpEscaper.js\";\nimport JavaEscaper from \"./escapes/JavaEscaper.js\";\nimport JavascriptEscaper from \"./escapes/JavascriptEscaper.js\";\nimport JsonEscaper from \"./escapes/JsonEscaper.js\";\nimport RegexBasedEscaper from \"./escapes/RegexBasedEscaper.js\";\nimport PHPEscaper from \"./escapes/PHPEscaper.js\";\nimport SmartyEscaper from \"./escapes/SmartyEscaper.js\";\nimport PythonEscaper from \"./escapes/PythonEscaper.js\";\nimport SwiftEscaper from \"./escapes/SwiftEscaper.js\";\nimport URIEscaper from \"./escapes/URIEscaper.js\";\n\nconst escaperCache = {};\n\n/**\n * Return an Escaper instance for the given style. The style must be one of the\n * following:\n * <ul>\n * <li>csharp - escape for C#</li>\n * <li>csharp-raw - escape for C# raw strings</li>\n * <li>csharp-verbatim - escape for C# verbatim strings</li>\n * <li>java - escape for Java</li>\n * <li>java-raw - escape for JSON raw strings</li>\n * <li>js - escape for JavaScript</li>\n * <li>javascript-template - escape for JavaScript template strings</li>\n * <li>json - escape for JSON</li>\n * <li>kotlin - escape for Kotlin</li>\n * <li>kotlin-raw - escape for Kotlin raw strings</li>\n * <li>php - escape for PHP (default, same as php-double)</li>\n * <li>php-double - escape for double-quoted PHP strings</li>\n * <li>php-single - escape for single-quoted PHP strings</li>\n * <li>php-heredoc - escape for PHP heredoc strings</li>\n * <li>php-nowdoc - escape for PHP nowdoc strings</li>\n * <li>python - escape for Python regular strings (default)</li>\n * <li>python-raw - escape for Python raw strings</li>\n * <li>python-byte - escape for Python byte strings</li>\n * <li>python-multi - escape for Python multi-line strings</li>\n * <li>regexp - escape for regular expressions</li>\n * <li>smarty - escape for Smarty templates (default, same as smarty-double)</li>\n * <li>smarty-double - escape for double-quoted Smarty strings</li>\n * <li>smarty-single - escape for single-quoted Smarty strings</li>\n * <li>swift - escape for regular Swift strings</li>\n * <li>swift-multi - escape for Swift multi-line strings</li>\n * <li>swift-extended - escape for Swift extended strings</li>\n * <li>uri - escape for URLs and URIs</li>\n * <li>xml - escape for XML text, including HTML</li>\n * <li>xml-attr - escape for XML attributes, including HTML</li>\n * </ul>\n * @param {string} style the style to use to determine how to escape\n * @returns {Escaper} a new Escaper instance, or undefined if the style\n * is not recognized\n */\nfunction escaperFactory(style) {\n if (style === \"html\") {\n style = \"xml\";\n }\n if (escaperCache[style]) {\n return escaperCache[style];\n }\n switch (style) {\n case 'csharp':\n case 'c#':\n case 'csharp-raw':\n case 'c#-raw':\n case 'csharp-verbatim':\n case 'c#-verbatim':\n escaperCache[style] = new CSharpEscaper(style);\n break;\n\n case 'kotlin':\n case 'kotlin-raw':\n case 'java':\n case 'java-raw':\n escaperCache[style] = new JavaEscaper(style);\n break;\n\n case 'json':\n escaperCache[style] = new JsonEscaper();\n break;\n\n case 'js':\n case 'js-template':\n case 'javascript':\n case 'javascript-template':\n escaperCache[style] = new JavascriptEscaper(style);\n break;\n\n case 'php':\n case 'php-double':\n case 'php-single':\n case 'php-heredoc':\n case 'php-nowdoc':\n escaperCache[style] = new PHPEscaper(style);\n break;\n\n case 'smarty':\n case 'smarty-double':\n case 'smarty-single':\n escaperCache[style] = new SmartyEscaper(style);\n break;\n\n case 'python':\n case 'python-raw':\n case 'python-byte':\n case 'python-multi':\n escaperCache[style] = new PythonEscaper(style);\n break;\n\n case 'swift':\n case 'swift-multi':\n case 'swift-extended':\n escaperCache[style] = new SwiftEscaper(style);\n break;\n\n case 'uri':\n case 'url':\n escaperCache[style] = new URIEscaper(style);\n break;\n\n default:\n try {\n escaperCache[style] = new RegexBasedEscaper(style);\n } catch (e) {\n // if the style is not recognized, just return undefined\n return undefined;\n }\n break;\n }\n return escaperCache[style];\n}\n\nexport default escaperFactory;"],"mappings":"gGAkBA,IAAAA,cAAA,CAAAC,sBAAA,CAAAC,OAAA,gCACA,IAAAC,YAAA,CAAAF,sBAAA,CAAAC,OAAA,8BACA,IAAAE,kBAAA,CAAAH,sBAAA,CAAAC,OAAA,oCACA,IAAAG,YAAA,CAAAJ,sBAAA,CAAAC,OAAA,8BACA,IAAAI,kBAAA,CAAAL,sBAAA,CAAAC,OAAA,oCACA,IAAAK,WAAA,CAAAN,sBAAA,CAAAC,OAAA,6BACA,IAAAM,cAAA,CAAAP,sBAAA,CAAAC,OAAA,gCACA,IAAAO,cAAA,CAAAR,sBAAA,CAAAC,OAAA,gCACA,IAAAQ,aAAA,CAAAT,sBAAA,CAAAC,OAAA,+BACA,IAAAS,WAAA,CAAAV,sBAAA,CAAAC,OAAA,6BAAiD,SAAAD,uBAAAW,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,EA3BjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAYA,GAAM,CAAAE,YAAY,CAAG,CAAC,CAAC,CAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,cAAcA,CAACC,KAAK,CAAE,CAC3B,GAAIA,KAAK,GAAK,MAAM,CAAE,CAClBA,KAAK,CAAG,KACZ,CACA,GAAIF,YAAY,CAACE,KAAK,C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,wBAAY,CAACR,KAAK,CAAC,CAC7C,MAEJ,IAAK,KAAK,CACV,IAAK,KAAK,CACNF,YAAY,CAACE,KAAK,CAAC,CAAG,GAAI,CAAAS,sBAAU,CAACT,KAAK,CAAC,CAC3C,MAEJ,QACI,GAAI,CACAF,YAAY,CAACE,KAAK,CAAC,CAAG,GAAI,CAAAU,6BAAiB,CAACV,KAAK,CACrD,CAAE,MAAOJ,CAAC,CAAE,CACR;AACA,MAAO,CAAAe,SACX,CACA,KACR,CACA,MAAO,CAAAb,YAAY,CAACE,KAAK,CAC7B,CAAC,IAAAY,QAAA,CAAAC,OAAA,YAEcd,cAAc,CAAAe,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"EscaperFactory.js","names":["_CppEscaper","_interopRequireDefault","require","_CSharpEscaper","_JavaEscaper","_JavascriptEscaper","_JsonEscaper","_RegexBasedEscaper","_PHPEscaper","_ScalaEscaper","_SmartyEscaper","_PythonEscaper","_SwiftEscaper","_URIEscaper","e","__esModule","escaperCache","escaperFactory","style","CppEscaper","CSharpEscaper","JavaEscaper","JsonEscaper","JavascriptEscaper","PHPEscaper","ScalaEscaper","SmartyEscaper","PythonEscaper","SwiftEscaper","URIEscaper","RegexBasedEscaper","undefined","_default","exports","module","default"],"sources":["../src/EscaperFactory.js"],"sourcesContent":["/*\n * EscaperFactory.js - factory function that returns escaper instances\n *\n * Copyright © 2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport CppEscaper from \"./escapes/CppEscaper.js\";\nimport CSharpEscaper from \"./escapes/CSharpEscaper.js\";\nimport JavaEscaper from \"./escapes/JavaEscaper.js\";\nimport JavascriptEscaper from \"./escapes/JavascriptEscaper.js\";\nimport JsonEscaper from \"./escapes/JsonEscaper.js\";\nimport RegexBasedEscaper from \"./escapes/RegexBasedEscaper.js\";\nimport PHPEscaper from \"./escapes/PHPEscaper.js\";\nimport ScalaEscaper from \"./escapes/ScalaEscaper.js\";\nimport SmartyEscaper from \"./escapes/SmartyEscaper.js\";\nimport PythonEscaper from \"./escapes/PythonEscaper.js\";\nimport SwiftEscaper from \"./escapes/SwiftEscaper.js\";\nimport URIEscaper from \"./escapes/URIEscaper.js\";\n\nconst escaperCache = {};\n\n/**\n * Return an Escaper instance for the given style. The style must be one of the\n * following:\n * <ul>\n * <li>cpp - escape for C++ regular strings</li>\n * <li>cpp-char - escape for C++ character literals</li>\n * <li>cpp-raw - escape for C++ raw strings</li>\n * <li>cpp-wide - escape for C++ wide strings</li>\n * <li>cpp-utf8 - escape for C++ UTF-8 strings</li>\n * <li>cpp-utf16 - escape for C++ UTF-16 strings</li>\n * <li>cpp-utf32 - escape for C++ UTF-32 strings</li>\n * <li>csharp - escape for C#</li>\n * <li>csharp-raw - escape for C# raw strings</li>\n * <li>csharp-verbatim - escape for C# verbatim strings</li>\n * <li>java - escape for Java</li>\n * <li>java-raw - escape for JSON raw strings</li>\n * <li>js - escape for JavaScript</li>\n * <li>javascript-template - escape for JavaScript template strings</li>\n * <li>json - escape for JSON</li>\n * <li>kotlin - escape for Kotlin</li>\n * <li>kotlin-raw - escape for Kotlin raw strings</li>\n * <li>php - escape for PHP (default, same as php-double)</li>\n * <li>php-double - escape for double-quoted PHP strings</li>\n * <li>php-single - escape for single-quoted PHP strings</li>\n * <li>php-heredoc - escape for PHP heredoc strings</li>\n * <li>php-nowdoc - escape for PHP nowdoc strings</li>\n * <li>python - escape for Python regular strings (default)</li>\n * <li>python-raw - escape for Python raw strings</li>\n * <li>python-byte - escape for Python byte strings</li>\n * <li>python-multi - escape for Python multi-line strings</li>\n * <li>regexp - escape for regular expressions</li>\n * <li>scala - escape for Scala regular strings</li>\n * <li>scala-raw - escape for Scala raw strings</li>\n * <li>scala-triple - escape for Scala triple-quoted strings</li>\n * <li>scala-char - escape for Scala character literals</li>\n * <li>smarty - escape for Smarty templates (default, same as smarty-double)</li>\n * <li>smarty-double - escape for double-quoted Smarty strings</li>\n * <li>smarty-single - escape for single-quoted Smarty strings</li>\n * <li>swift - escape for regular Swift strings</li>\n * <li>swift-multi - escape for Swift multi-line strings</li>\n * <li>swift-extended - escape for Swift extended strings</li>\n * <li>uri - escape for URLs and URIs</li>\n * <li>xml - escape for XML text, including HTML</li>\n * <li>xml-attr - escape for XML attributes, including HTML</li>\n * </ul>\n * @param {string} style the style to use to determine how to escape\n * @returns {Escaper} a new Escaper instance, or undefined if the style\n * is not recognized\n */\nfunction escaperFactory(style) {\n if (style === \"html\") {\n style = \"xml\";\n }\n if (escaperCache[style]) {\n return escaperCache[style];\n }\n switch (style) {\n case 'cpp':\n case 'cpp-char':\n case 'cpp-raw':\n case 'cpp-wide':\n case 'cpp-utf8':\n case 'cpp-utf16':\n case 'cpp-utf32':\n escaperCache[style] = new CppEscaper(style);\n break;\n\n case 'csharp':\n case 'c#':\n case 'csharp-raw':\n case 'c#-raw':\n case 'csharp-verbatim':\n case 'c#-verbatim':\n escaperCache[style] = new CSharpEscaper(style);\n break;\n\n case 'kotlin':\n case 'kotlin-raw':\n case 'java':\n case 'java-raw':\n escaperCache[style] = new JavaEscaper(style);\n break;\n\n case 'json':\n escaperCache[style] = new JsonEscaper();\n break;\n\n case 'js':\n case 'js-template':\n case 'javascript':\n case 'javascript-template':\n escaperCache[style] = new JavascriptEscaper(style);\n break;\n\n case 'php':\n case 'php-double':\n case 'php-single':\n case 'php-heredoc':\n case 'php-nowdoc':\n escaperCache[style] = new PHPEscaper(style);\n break;\n\n case 'scala':\n case 'scala-raw':\n case 'scala-triple':\n case 'scala-char':\n escaperCache[style] = new ScalaEscaper(style);\n break;\n\n case 'smarty':\n case 'smarty-double':\n case 'smarty-single':\n escaperCache[style] = new SmartyEscaper(style);\n break;\n\n case 'python':\n case 'python-raw':\n case 'python-byte':\n case 'python-multi':\n escaperCache[style] = new PythonEscaper(style);\n break;\n\n case 'swift':\n case 'swift-multi':\n case 'swift-extended':\n escaperCache[style] = new SwiftEscaper(style);\n break;\n\n case 'uri':\n case 'url':\n escaperCache[style] = new URIEscaper(style);\n break;\n\n default:\n try {\n escaperCache[style] = new RegexBasedEscaper(style);\n } catch (e) {\n // if the style is not recognized, just return undefined\n return undefined;\n }\n break;\n }\n return escaperCache[style];\n}\n\nexport default escaperFactory;"],"mappings":"gGAkBA,IAAAA,WAAA,CAAAC,sBAAA,CAAAC,OAAA,6BACA,IAAAC,cAAA,CAAAF,sBAAA,CAAAC,OAAA,gCACA,IAAAE,YAAA,CAAAH,sBAAA,CAAAC,OAAA,8BACA,IAAAG,kBAAA,CAAAJ,sBAAA,CAAAC,OAAA,oCACA,IAAAI,YAAA,CAAAL,sBAAA,CAAAC,OAAA,8BACA,IAAAK,kBAAA,CAAAN,sBAAA,CAAAC,OAAA,oCACA,IAAAM,WAAA,CAAAP,sBAAA,CAAAC,OAAA,6BACA,IAAAO,aAAA,CAAAR,sBAAA,CAAAC,OAAA,+BACA,IAAAQ,cAAA,CAAAT,sBAAA,CAAAC,OAAA,gCACA,IAAAS,cAAA,CAAAV,sBAAA,CAAAC,OAAA,gCACA,IAAAU,aAAA,CAAAX,sBAAA,CAAAC,OAAA,+BACA,IAAAW,WAAA,CAAAZ,sBAAA,CAAAC,OAAA,6BAAiD,SAAAD,uBAAAa,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,EA7BjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAcA,GAAM,CAAAE,YAAY,CAAG,CAAC,CAAC,CAEvB;AACA;AACA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typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _Escaper2=_interopRequireDefault(require("./Escaper.js"));var _EscapeCommon=require("./EscapeCommon.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}/*
|
|
2
|
+
* CppEscaper.js - class that escapes and unescapes strings in C++
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2025 JEDLSoft
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
*
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/var validStyles=new Set(["cpp",// regular double-quoted strings
|
|
19
|
+
"cpp-char",// character literals like 'a'
|
|
20
|
+
"cpp-raw",// raw strings like R"(foo)"
|
|
21
|
+
"cpp-wide",// wide strings like L"foo"
|
|
22
|
+
"cpp-utf8",// UTF-8 strings like u8"foo"
|
|
23
|
+
"cpp-utf16",// UTF-16 strings like u"foo"
|
|
24
|
+
"cpp-utf32"// UTF-32 strings like U"foo"
|
|
25
|
+
]);/**
|
|
26
|
+
* @class Escaper for C++
|
|
27
|
+
*/var CppEscaper=/*#__PURE__*/function(_Escaper){/**
|
|
28
|
+
* Can support the following styles:
|
|
29
|
+
* - cpp: regular double-quoted strings
|
|
30
|
+
* - cpp-char: character literals like 'a'
|
|
31
|
+
* - cpp-raw: raw strings like R"(foo)"
|
|
32
|
+
* - cpp-wide: wide strings like L"foo"
|
|
33
|
+
* - cpp-utf8: UTF-8 strings like u8"foo"
|
|
34
|
+
* - cpp-utf16: UTF-16 strings like u"foo"
|
|
35
|
+
* - cpp-utf32: UTF-32 strings like U"foo"
|
|
36
|
+
*
|
|
37
|
+
* @param {string} style the style to use for escaping
|
|
38
|
+
* @constructor
|
|
39
|
+
* @throws {Error} if the style is not supported
|
|
40
|
+
*/function CppEscaper(style){var _this;_classCallCheck(this,CppEscaper);_this=_callSuper(this,CppEscaper,[style]);if(!validStyles.has(style)){throw new Error("invalid cpp escape style ".concat(style))}_this.name="cpp-escaper";_this.description="Escapes and unescapes various types of strings in C++";return _this}/**
|
|
41
|
+
* @override
|
|
42
|
+
*/_inherits(CppEscaper,_Escaper);return _createClass(CppEscaper,[{key:"escape",value:function escape(string){var escaped=string;escaped=(0,_EscapeCommon.escapeRules)(escaped,_EscapeCommon.escapeRegexes[this.style]);// Apply Unicode escaping for all C++ string types except raw strings
|
|
43
|
+
// C++ supports Unicode escapes in all string types except raw strings
|
|
44
|
+
if(this.style!=="cpp-raw"){escaped=(0,_EscapeCommon.escapeUnicodeAsSurrogatePairs)(escaped)}return escaped}/**
|
|
45
|
+
* @override
|
|
46
|
+
*/},{key:"unescape",value:function unescape(string){var unescaped=string;// Apply Unicode unescaping for all C++ string types except raw strings
|
|
47
|
+
if(this.style!=="cpp-raw"){unescaped=(0,_EscapeCommon.unescapeUnicode)(unescaped)}unescaped=(0,_EscapeCommon.unescapeRules)(unescaped,_EscapeCommon.escapeRegexes[this.style]);return unescaped}}])}(_Escaper2["default"]);var _default=exports["default"]=CppEscaper;module.exports=exports.default;
|
|
48
|
+
//# sourceMappingURL=CppEscaper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CppEscaper.js","names":["_Escaper2","_interopRequireDefault","require","_EscapeCommon","e","__esModule","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","o","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","prototype","i","_toPrimitive","_typeof","Symbol","toPrimitive","call","String","Number","_callSuper","_getPrototypeOf","_possibleConstructorReturn","_isNativeReflectConstruct","Reflect","construct","constructor","apply","_assertThisInitialized","ReferenceError","Boolean","valueOf","setPrototypeOf","getPrototypeOf","bind","__proto__","_inherits","create","value","_setPrototypeOf","validStyles","Set","CppEscaper","_Escaper","style","_this","has","Error","concat","name","description","escape","string","escaped","escapeRules","escapeRegexes","escapeUnicodeAsSurrogatePairs","unescape","unescaped","unescapeUnicode","unescapeRules","Escaper","_default","exports","module","default"],"sources":["../../src/escapes/CppEscaper.js"],"sourcesContent":["/*\n * CppEscaper.js - class that escapes and unescapes strings in C++\n *\n * Copyright © 2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Escaper from './Escaper.js';\nimport {\n escapeUnicodeAsSurrogatePairs,\n escapeRules,\n unescapeRules,\n unescapeUnicode,\n escapeRegexes\n} from './EscapeCommon.js';\n\nconst validStyles = new Set([\n \"cpp\", // regular double-quoted strings\n \"cpp-char\", // character literals like 'a'\n \"cpp-raw\", // raw strings like R\"(foo)\"\n \"cpp-wide\", // wide strings like L\"foo\"\n \"cpp-utf8\", // UTF-8 strings like u8\"foo\"\n \"cpp-utf16\", // UTF-16 strings like u\"foo\"\n \"cpp-utf32\" // UTF-32 strings like U\"foo\"\n]);\n\n/**\n * @class Escaper for C++\n */\nclass CppEscaper extends Escaper {\n /**\n * Can support the following styles:\n * - cpp: regular double-quoted strings\n * - cpp-char: character literals like 'a'\n * - cpp-raw: raw strings like R\"(foo)\"\n * - cpp-wide: wide strings like L\"foo\"\n * - cpp-utf8: UTF-8 strings like u8\"foo\"\n * - cpp-utf16: UTF-16 strings like u\"foo\"\n * - cpp-utf32: UTF-32 strings like U\"foo\"\n *\n * @param {string} style the style to use for escaping\n * @constructor\n * @throws {Error} if the style is not supported\n */\n constructor(style) {\n super(style);\n if (!validStyles.has(style)) {\n throw new Error(`invalid cpp escape style ${style}`);\n }\n this.name = \"cpp-escaper\";\n this.description = \"Escapes and unescapes various types of strings in C++\";\n }\n\n /**\n * @override\n */\n escape(string) {\n let escaped = string;\n\n escaped = escapeRules(escaped, escapeRegexes[this.style]);\n\n // Apply Unicode escaping for all C++ string types except raw strings\n // C++ supports Unicode escapes in all string types except raw strings\n if (this.style !== \"cpp-raw\") {\n escaped = escapeUnicodeAsSurrogatePairs(escaped);\n }\n\n return escaped;\n }\n\n /**\n * @override\n */\n unescape(string) {\n let unescaped = string;\n\n // Apply Unicode unescaping for all C++ string types except raw strings\n if (this.style !== \"cpp-raw\") {\n unescaped = unescapeUnicode(unescaped);\n }\n\n unescaped = unescapeRules(unescaped, escapeRegexes[this.style]);\n\n return unescaped;\n }\n}\n\nexport default CppEscaper; "],"mappings":"kXAmBA,IAAAA,SAAA,CAAAC,sBAAA,CAAAC,OAAA,kBACA,IAAAC,aAAA,CAAAD,OAAA,sBAM2B,SAAAD,uBAAAG,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,WAAAE,gBAAAC,CAAA,CAAAC,CAAA,OAAAD,CAAA,YAAAC,CAAA,YAAAC,SAAA,+CAAAC,kBAAAN,CAAA,CAAAO,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAD,CAAA,CAAAE,MAAA,CAAAD,CAAA,QAAAE,CAAA,CAAAH,CAAA,CAAAC,CAAA,EAAAE,CAA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MAAM,CAAE,CACb,GAAI,CAAAM,SAAS,CAAGN,MAAM,CAEtB;AACA,GAAI,IAAI,CAACR,KAAK,GAAK,SAAS,CAAE,CAC1Bc,SAAS,CAAG,GAAAC,6BAAe,EAACD,SAAS,CACzC,CAEAA,SAAS,CAAG,GAAAE,2BAAa,EAACF,SAAS,CAAEH,2BAAa,CAAC,IAAI,CAACX,KAAK,CAAC,CAAC,CAE/D,MAAO,CAAAc,SACX,CAAC,KAvDoBG,oBAAO,MAAAC,QAAA,CAAAC,OAAA,YA0DjBrB,UAAU,CAAAsB,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
|
@@ -51,7 +51,33 @@
|
|
|
51
51
|
},"escape":{"\"":"\"\""// escape quotes
|
|
52
52
|
}},"csharp-raw":{"unescape":{// none
|
|
53
53
|
},"escape":{// none
|
|
54
|
-
}}
|
|
54
|
+
}},// from https://en.cppreference.com/w/cpp/language/string_literal
|
|
55
|
+
"cpp":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
56
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
57
|
+
"^\\\\'":"'",// unescape single quotes
|
|
58
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
59
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-char":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
60
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
61
|
+
"^\\\\'":"'",// unescape single quotes
|
|
62
|
+
"([^\\\\])\\\\'":"$1'","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-raw":{"unescape":{// raw strings don't unescape anything
|
|
63
|
+
},"escape":{// raw strings don't escape anything
|
|
64
|
+
}},"cpp-wide":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
65
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
66
|
+
"^\\\\'":"'",// unescape single quotes
|
|
67
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
68
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-utf8":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
69
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
70
|
+
"^\\\\'":"'",// unescape single quotes
|
|
71
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
72
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-utf16":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
73
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
74
|
+
"^\\\\'":"'",// unescape single quotes
|
|
75
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
76
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-utf32":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
77
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
78
|
+
"^\\\\'":"'",// unescape single quotes
|
|
79
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
80
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"java":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
55
81
|
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
56
82
|
"^\\\\'":"'",// unescape quotes
|
|
57
83
|
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"","([^\\\\])\\\\\"":"$1\"","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"}},"java-raw":{"unescape":{"\\\\\\\\n":"",// line continuation
|
|
@@ -87,7 +113,21 @@
|
|
|
87
113
|
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
88
114
|
"^\\\\\"":"\"",// unescape double quotes only, not single
|
|
89
115
|
"([^\\\\])\\\\\"":"$1\"",// unescape double quotes only, not single
|
|
90
|
-
"\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\b":"\b","\\\\f":"\f","\\\\v":"\x0B","\\\\a":"\x07"},"escape":{"([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","\\n":"\\n","\\r":"\\r","\\t":"\\t","\b":"\\b","\\f":"\\f","\\v":"\\v","\x07":"\\a"}},// from https://docs.
|
|
116
|
+
"\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\b":"\b","\\\\f":"\f","\\\\v":"\x0B","\\\\a":"\x07"},"escape":{"([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","\\n":"\\n","\\r":"\\r","\\t":"\\t","\b":"\\b","\\f":"\\f","\\v":"\\v","\x07":"\\a"}},// from https://docs.scala-lang.org/scala3/book/strings.html
|
|
117
|
+
"scala":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
118
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
119
|
+
"^\\\\'":"'",// unescape single quotes
|
|
120
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
121
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"}},"scala-raw":{"unescape":{// raw strings don't unescape anything
|
|
122
|
+
},"escape":{// raw strings don't escape anything
|
|
123
|
+
}},"scala-triple":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
124
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
125
|
+
"^\\\\'":"'",// unescape single quotes
|
|
126
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
127
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\n":"\\\\n","\r":"\\\\r","\t":"\\\\t"}},"scala-char":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
128
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
129
|
+
"^\\\\'":"'",// unescape single quotes
|
|
130
|
+
"([^\\\\])\\\\'":"$1'","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^'":"\\'","([^\\\\])'":"$1\\'","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"}},// from https://docs.swift.org/swift-book/documentation/the-swift-programming-language/stringsandcharacters
|
|
91
131
|
"swift":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
92
132
|
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
93
133
|
"^\\\\'":"'",// unescape single quotes
|
|
@@ -137,7 +177,13 @@
|
|
|
137
177
|
* @static
|
|
138
178
|
*/function escapeUnicodeAsSurrogatePairs(string){if(!string){return""}var output="";// access the original string character by character to get
|
|
139
179
|
// the surrogate pairs for code points above U+FFFF
|
|
140
|
-
for(var i=0;i<string.length;i++){var ch=string[i];var code=ch.charCodeAt(0)
|
|
180
|
+
for(var i=0;i<string.length;i++){var ch=string[i];var code=ch.charCodeAt(0);// Check if this is a high surrogate (first part of surrogate pair)
|
|
181
|
+
if(code>=55296&&code<=56319){// This is a high surrogate, get the low surrogate
|
|
182
|
+
var lowCode=string.charCodeAt(i+1);if(lowCode>=56320&&lowCode<=57343){// Calculate the full code point
|
|
183
|
+
var fullCode=(code-55296)*1024+(lowCode-56320)+65536;var high=Math.floor((fullCode-65536)/1024)+55296;var low=(fullCode-65536)%1024+56320;output+="\\u"+high.toString(16).toUpperCase()+"\\u"+low.toString(16).toUpperCase();i++;// Skip the low surrogate
|
|
184
|
+
continue}}// Check if this is a low surrogate (shouldn't happen in valid UTF-16)
|
|
185
|
+
if(code>=56320&&code<=57343){continue;// Skip low surrogates that weren't paired
|
|
186
|
+
}if(code<65536&&code>255){var str=code.toString(16).toUpperCase();output+="\\u"+str}else{output+=ch}}return output}/**
|
|
141
187
|
* Escape a string so that it has hexadecimal escape sequences
|
|
142
188
|
* in it instead of the characters themselves. This function
|
|
143
189
|
* will only convert characters from U+0000 to U+001F. The rest
|