pinyin4j icon indicating copy to clipboard operation
pinyin4j copied to clipboard

部分拼音存在编码错误, 如"老":"lăo", 这个ă不是标准拼音,而应该是ǎ

Open git-boya opened this issue 1 year ago • 2 comments

ă的unicode码:[259] ǎ的unicode码:[462] 两个a长的差不多, 但是不是一样字符.

git-boya avatar Jan 03 '25 02:01 git-boya

ă的unicode码:[259] ǎ的unicode码:[462] 两个a长的差不多, 但是不是一样字符.

请问是怎么解决的,我也遇到了

hjj-lmx avatar Jul 04 '25 03:07 hjj-lmx

ă的unicode码:[259] ǎ的unicode码:[462] 两个a长的差不多, 但是不是一样字符.

请问是怎么解决的,我也遇到了

这个库生成的拼音, 只有3声的编码不对, 把源码中的ăĕĭŭŏ替换成ǎěǐǔǒ, 或者在使用端转换一下

参考:

var wordPinyin = word.pinyin!.trim().replaceAllMapped(RegExp(r'[ăĕĭŭŏ]'), (Match match) {
            if (match[0]! == 'ă') return 'ǎ';
            if (match[0]! == 'ĕ') return 'ě';
            if (match[0]! == 'ĭ') return 'ǐ';
            if (match[0]! == 'ŭ') return 'ǔ';
            if (match[0]! == 'ŏ') return 'ǒ';
            return match[0]!;
          });

git-boya avatar Jul 04 '25 04:07 git-boya