chinese-character
操作中文字符串
安装
npm install chinese-character
用法
var chinese = ; //unicode 编码,类似 \u4e2d\u6587 的相互转换,var str=chinese;console;var str=chinese;console; //unicode10 编码,类似 中文 的相互转换,var str=chinese;console; var str=chinese;console; //unicode16 编码,类似 中文 的相互转换,var str=chinese;console; var str=chinese;console; //html 编码,类似 '< >"& 的相互转换,var str=chinese;console; var str=chinese;console; //字符串首字母var str=chinese;console; //返回 g //字符串首字母连接var str=chinese;console; //返回 gjdk //字符串首字母数组var str=chinese;console; //返回[ 'g', 'j', 'd', 'k' ] //字符串首字母的拼音var str=chinese;console; //返回guo //字符串首字母的拼音连接var str=chinese;console; //返回guojiaduikang //字符串首字母的拼音数组var str=chinese;console; //返回[ 'guo', 'jia', 'dui', 'kang' ] //字符串首字母的声调拼音var str=chinese;console; //返回guó //字符串首字母的声调拼音连接var str=chinese;console; //返回guójiāduìkàng //字符串首字母的声调拼音数组var str=chinese;console; //返回[ 'guó', 'jiā', 'duì', 'kàng' ] //字符串首字母的声调var str=chinese;console; //返回2 //字符串首字母的声调连接var str=chinese;console; //返回2144 //字符串首字母的声调数组var str=chinese;console; //返回[ 2, 1, 4, 4 ] //字符串内中文字数,默认不含标点符号var str=chinese;console; //返回4 //字符串内中文字数,含标点符号var str=chinese;console; //返回5 //数组内对象的中文属性排序var str=chinese;console; /*返回[ { title: '白天' }, { title: '你好' }, { title: '宁静' }, { title: '世界' }, { title: '时间' }, { title: '闪电' } ]*/ //数组内中文排序var str=chinese;console; //返回 [ '白天', '你好', '宁静', '世界', '时间', '闪电' ] //数组内对象的中文属性排序后分组var str=chinese;console; /* 返回[ { first: 'b', data: [ [Object] ] }, { first: 'n', data: [ [Object], [Object] ] }, { first: 's', data: [ [Object], [Object], [Object] ] } ]*/ //数组内中文排序后分组var str=chinese;console; /* 返回[ { first: 'b', data: [ '白天' ] }, { first: 'n', data: [ '你好', '宁静' ] }, { first: 's', data: [ '世界', '时间', '闪电' ] } ]*/