UNPKG

turbocommons-ts

Version:

General purpose library that implements frequently used and generic software development tasks

1 lines 732 B
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EncodingUtils=void 0;var StringUtils_1=require("./StringUtils"),EncodingUtils=function(){function t(){}return t.unicodeEscapedCharsToUtf8=function(t){if(StringUtils_1.StringUtils.isString(t))return t.replace(/\\u([\d\w]{4})/gi,function(t,i){return String.fromCharCode(parseInt(i,16))});throw new Error("Specified value must be a string")},t.utf8ToUnicodeEscapedChars=function(t){if(!StringUtils_1.StringUtils.isString(t))throw new Error("Specified value must be a string");return StringUtils_1.StringUtils.isEmpty(t)?t:t.replace(/[^\0-~]/g,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})},t}();exports.EncodingUtils=EncodingUtils;