gb2312-hex
v1.1.0
Published
英文字符用ascii编码,中文字符用gb2312编码,并可以16进制互相转换
Downloads
46
Maintainers
Readme
英文字符用ascii编码,中文字符用gb2312编码,并可以16进制互相转换
import { encodeToGb2312HexList, decodeFromGb2312HexList } from 'gb2312-hex';
const txt = `
我爱你中国...
Abcd12345.
拉 ¡ 拉
`;
console.log(encodeToGb2312HexList(txt));
/*
[
'0A', '20', '20', '20', '20', '20', '20',
'20', '20', 'CE', 'D2', 'B0', 'AE', 'C4',
'E3', 'D6', 'D0', 'B9', 'FA', '2E', '2E',
'2E', '0A', '20', '20', '20', '20', '20',
'20', '20', '20', '41', '62', '63', '64',
'31', '32', '33', '34', '35', '2E', '0A',
'20', '20', '20', '20', '20', '20', '20',
'20', 'C0', 'AD', '20', '20', '20', '20',
'C0', 'AD', '0A', '20', '20', '20', '20'
]
*/
console.log(decodeFromGb2312HexList(encodeToGb2312HexList(txt)));
/*
我爱你中国...
Abcd12345.
拉 ¡ 拉
*/