Skip to content

Instantly share code, notes, and snippets.

@jarvisniu
Last active February 11, 2019 15:58
Show Gist options
  • Select an option

  • Save jarvisniu/cd1f9a82ff412b34a565430e417f9c7b to your computer and use it in GitHub Desktop.

Select an option

Save jarvisniu/cd1f9a82ff412b34a565430e417f9c7b to your computer and use it in GitHub Desktop.
判断字符是否是全宽 Detect whether a char full width
// 判断字符是否是全宽(中日韩文字及符号)
function isFullWidth (char) {
// 【文档】
// Unicode区块查询: https://unicodelookup.com
// 字符到HEX: '!'.charCodeAt(0).toString(16)
// HEX到字符: String.fromCharCode('0xff58')
// 【易弄错半宽】
// 半宽中文标点1: (2013|–)~(201d|”)
// 半宽中文标点2(。)、半宽片假名katakana(ヲ)、半宽韩文字母hangul(ᄀ): (ff61|。)~(201d|”)
// 【全宽字符】
// 5 中文符号1: (3001|、)~(3020|〠)
// 3.日文: (3031|〱)~(33ff|㏿)
// 2.生僻中文: (3400|㐀)~(4dff|䷿)
// 1.常用中文: (4e00|一)~(9fd5|鿕)
// 4.韩文: (ac00|가)~(d7a3|힣)
// 6.中文符号2、全宽英文符号、全宽数字字母: (ff01|!)~(ff60|⦆):?¥
// 7.全宽货币符号: (ffe0|¢)~(ffe6|₩)
// 8.扩展D区(急用汉字): (2B740|띀)~(2B81D|렝)
return /[一-鿕|㐀-䷿|〱-㏿|가-힣|、-〠|!-⦆|¢-₩|띀-렝]/.test(char)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment