Qinsam/pinyin4cpp
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
# pinyin4cpp
pinyin4j cpp版本
1、目前不支持多音字,汉子有多个拼音时,出其中一个
2、在pinyin4j的基础上做了一些性能改进,减少字符串操作
3、中文和拼音对应文件编到代码里了,使用时不需要字典文件
4、支持输出简拼
依赖:boost
install:
./configure --prefix= $(install_dir)
make
make install
通过头文件和动态库使用
demo/test.cc 编译生成 $(install_dir)/bin/test
用法:
PinyinHelper ph;
HanyuPinyinOutputFormat hpof;
hpof.setCaseType(HanyuPinyinCaseType::UPPERCASE); //拼音大写
hpof.setCaseType(HanyuPinyinCaseType::LOWERCASE); //拼音小写(默认值)
hpof.setToneType(HanyuPinyinToneType::WITHOUT_TONE); //不要声调
hpof.setToneType(HanyuPinyinToneType::WITH_TONE_NUMBER); //声调放在拼音后面用数字表示(默认值)
hpof.setVCharType(HanyuPinyinVCharType::WITH_U_AND_COLON); //u:转成ü
hpof.setVCharType(HanyuPinyinVCharType::WITH_V); //u:转成v (默认值)
hpof.setSpellType(HanyuPinyinSpellType::FIRST_LETTER); //首字母简拼
hpof.setSpellType(HanyuPinyinSpellType::FULL_LETTER); //全拼(默认值)
string res=ph.toHanYuPinyinString(s,hpof);