美文网首页
小工具:获取汉字全拼及简拼

小工具:获取汉字全拼及简拼

作者: 鱼da王 | 来源:发表于2019-03-01 11:27 被阅读0次
  1. 工具:com.github.stuxuhai

  2. maven:

            <dependency>
                <groupId>com.github.stuxuhai</groupId>
                <artifactId>jpinyin</artifactId>
                <version>1.1.7</version>
            </dependency>
    
  3. API使用

    String str = "你好世界";
    PinyinHelper.convertToPinyinString(str, ",", PinyinFormat.WITH_TONE_MARK); // nǐ,hǎo,shì,jiè
    PinyinHelper.convertToPinyinString(str, ",", PinyinFormat.WITH_TONE_NUMBER); // ni3,hao3,shi4,jie4
    PinyinHelper.convertToPinyinString(str, ",", PinyinFormat.WITHOUT_TONE); // ni,hao,shi,jie
    PinyinHelper.getShortPinyin(str); // nhsj
    PinyinHelper.addPinyinDict("user.dict");  // 添加用户自定义字典
    
  4. github地址

    https://github.com/qzw1210/jpinyin

相关文章

网友评论

      本文标题:小工具:获取汉字全拼及简拼

      本文链接:https://www.haomeiwen.com/subject/bjoruqtx.html