Files
NapCatQQ/.pnpm-store/v3/files/8f/44ffd94399ea55e3516b2668ae173554baa0099b62dd2f4bb39e5c04966dabd16a91dcdf078eb495bb1128ea4680fff41ae87c9dda7057015079d560b38582
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

26 lines
652 B
Plaintext

/**
* @file unicode字符转xml字符编码
* @author mengke01(kekee000@gmail.com)
*/
import string from '../../common/string';
/**
* unicode 转xml编码格式
*
* @param {Array.<number>} unicodeList unicode字符列表
* @return {string} xml编码格式
*/
export default function unicode2xml(unicodeList) {
if (typeof unicodeList === 'number') {
unicodeList = [unicodeList];
}
return unicodeList.map(u => {
if (u < 0x20) {
return '';
}
return u >= 0x20 && u <= 255
? string.encodeHTML(String.fromCharCode(u))
: '&#x' + u.toString(16) + ';';
}).join('');
}