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 19 | 1x 1x 10x 1x | /**
* 全角字符转半角字符
* @method dbcToSbc
* @param {String} str 包含了全角字符的字符串
* @return {String} 经过转换的字符串
* @example
* import { dbcToSbc } from '@spore-ui/tskit';
* dbcToSbc('SAASDFSADF'); // 'SAASDFSADF'
*/
export function dbcToSbc(str: string): string {
return str.replace(
(/[\uff01-\uff5e]/g),
(a: string): string => (String.fromCharCode(a.charCodeAt(0) - 65248)),
).replace(/\u3000/g, ' ');
}
export default dbcToSbc;
|