美文网首页
Java简繁体中文互换

Java简繁体中文互换

作者: CentForever | 来源:发表于2021-01-25 00:00 被阅读0次

    title: Java简繁体中文互换
    date: 2019-11-18 17:40:50
    categories:
    - pinyin
    tags:
    - 简繁体


        implementation files('libs/jcc-bate-0.7.3.jar')
        implementation files('libs/ZHConverter.jar')
    
    //简体转成繁体  s2t
        public static String s2t(String changeText) {
            try {
                JChineseConvertor jChineseConvertor = JChineseConvertor
                        .getInstance();
                changeText = jChineseConvertor.s2t(changeText);
            } catch (Exception e) {
                e.printStackTrace();
                try {
                    ZHConverter converter = ZHConverter.getInstance(ZHConverter.TRADITIONAL);
                    changeText = converter.convert(changeText);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            return changeText;
        }
    
      //繁体转成简体
        public static String t2s(String changeText) {
            try {
                JChineseConvertor jChineseConvertor = JChineseConvertor
                        .getInstance();
                changeText = jChineseConvertor.t2s(changeText);
            } catch (Exception e) {
                e.printStackTrace();
                try {
                    ZHConverter converter = ZHConverter.getInstance(ZHConverter.SIMPLIFIED);
                    changeText = converter.convert(changeText);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            return changeText;
        }
    

    相关文章

      网友评论

          本文标题:Java简繁体中文互换

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