fonteditor-core
Version:
fonts (ttf, woff, woff2, eot, svg, otf) parse, write, transform, glyph adjust.
30 lines (28 loc) • 834 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = unicode2xml;
var _string = _interopRequireDefault(require("../../common/string"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @file unicode字符转xml字符编码
* @author mengke01(kekee000@gmail.com)
*/
/**
* unicode 转xml编码格式
*
* @param {Array.<number>} unicodeList unicode字符列表
* @return {string} xml编码格式
*/
function unicode2xml(unicodeList) {
if (typeof unicodeList === 'number') {
unicodeList = [unicodeList];
}
return unicodeList.map(function (u) {
if (u < 0x20) {
return '';
}
return u >= 0x20 && u <= 255 ? _string.default.encodeHTML(String.fromCharCode(u)) : '&#x' + u.toString(16) + ';';
}).join('');
}