久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      java怎么判斷字符串是否中文

      java怎么判斷字符串是否中文

      Java用的是Unicode 編碼char 型變量的范圍是0-65535 無(wú)符號(hào)的值,可以表示 65536個(gè)字符,基本上地球上的字符可被全部包括了

      漢字基本集中在[19968,40869]之間,共有20901個(gè)漢字。

      unicode編碼范圍:

      漢字:[0x4e00,0x9fa5](或十進(jìn)制[19968,40869])

      數(shù)字:[0x30,0x39](或十進(jìn)制[48, 57])

      小寫字母:[0x61,0x7a](或十進(jìn)制[97, 122])

      大寫字母:[0x41,0x5a](或十進(jìn)制[65, 90])

      第一種 判斷是否存在漢字

      public boolean checkcountname(String countname)     {          Pattern p = Pattern.compile("[u4e00-u9fa5]");             Matcher m = p.matcher(countname);             if (m.find()) {                 return true;             }             return false;     }

      用正則表達(dá)式去匹配

      第二種 判斷整個(gè)字符串都由漢字組成

      public boolean checkname(String name)     {         int n = 0;         for(int i = 0; i < name.length(); i++) {             n = (int)name.charAt(i);             if(!(19968 <= n && n <40869)) {                 return false;             }         }         return true;     }

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)