Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1x 10x 1x | /**
* 全角字符转半角字符
* @method str/dbcToSbc
* @param {String} str 包含了全角字符的字符串
* @returns {String} 经过转换的字符串
* @example
* var $dbcToSbc = require('@spore-ui/kit/packages/str/dbcToSbc');
* $dbcToSbc('SAASDFSADF'); // 'SAASDFSADF'
*/
function dbcToSbc(str) {
return str.replace(/[\uff01-\uff5e]/g, function (a) {
return String.fromCharCode(a.charCodeAt(0) - 65248);
}).replace(/\u3000/g, ' ');
}
module.exports = dbcToSbc;
|