belerweb / pinyin4j

A copy of http://sourceforge.net/projects/pinyin4j, then deploy it to maven central repository.
1.24k stars 308 forks source link

张字转拼音 是我使用问题嘛? #36

Closed Shimizusorrow closed 3 years ago

Shimizusorrow commented 3 years ago
@Test
    void test() {
        HanyuPinyinOutputFormat fmt = new HanyuPinyinOutputFormat();
        fmt.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
//        fmt.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        String[] pinyin_z = PinyinHelper.toHanyuPinyinStringArray('张');
        String[] pinyin_l = PinyinHelper.toHanyuPinyinStringArray('李');
        String[] z = PinyinHelper.toTongyongPinyinStringArray('张');
        String[] l = PinyinHelper.toTongyongPinyinStringArray('李');
        System.out.println(Stream.of(z).collect(Collectors.toList()).toString());
        System.out.println(Stream.of(l).collect(Collectors.toList()).toString());
        System.out.println(Stream.of(pinyin_z).collect(Collectors.toList()).toString());
        System.out.println(Stream.of(pinyin_l).collect(Collectors.toList()).toString());

    }

output: [jhang1] [li3] [zhang1] [li3]