[pinyin4j] java版汉字转换拼音(大小写)

开发技术 作者: 2024-06-17 23:25:01
pinyin4J 是一个可以将汉字转换成拼音的lib,非常实用,其maven地址为:http://mvnrepository.com/artifact/com.belerweb/pinyin4j/2.5.0pinyin4J 提供PinyinHelper这个静态类对外提供拼音转换的服务,主要有一下方法

pinyin4J 是1个可以将汉字转换成拼音的lib,非常实用,其maven地址为:http://mvnrepository.com/artifact/com.belerweb/pinyin4j/2.5.0


pinyin4J 提供PinyinHelper这个静态类对外提供拼音转换的服务,主要有1下方法:

static public String[] toHanyuPinyinStringArray(char ch)

将char(必须为汉字单字)转化为拼音,实用的是通用的格式,如果ch为非汉字,返回null。

输入:重 输出:[zhong4,chong2] 说明重字有两个读音,拼音后面的1,2,3,4 代表的是读音


static public String[] toHanyuPinyinStringArray(char ch,HanyuPinyinOutputFormat outputFormat)

同上,但是这个方法可以设置输出的格式。HanyuPinyinOutputFormat   可以设置拼音大小写、是不是后面加读音数字、特殊读音的显示方式,定义以下:

/** * The option indicates that the output of 'ü' is "u:" */ public static final HanyuPinyinVCharType WITH_U_AND_COLON = new HanyuPinyinVCharType("WITH_U_AND_COLON"); /** * The option indicates that the output of 'ü' is "v" */ public static final HanyuPinyinVCharType WITH_V = new HanyuPinyinVCharType("WITH_V") /** * The option indicates that the output of 'ü' is "ü" in Unicode form */ public static final HanyuPinyinVCharType WITH_U_UNICODE = new HanyuPinyinVCharType("WITH_U_UNICODE");


static public String[] toTongyongPinyinStringArray(char ch)

转换为通用拼音。通用拼音的介绍见:http://zh.wikipedia.org/zh-cn/%E9%80%9A%E7%94%A8%E6%8B%BC%E9%9F%B3


static public String[] toWadeGilesPinyinStringArray(char ch)

转换为威妥玛拼音:http://zh.wikipedia.org/wiki/%E5%A8%81%E5%A6%A5%E7%91%AA%E6%8B%BC%E9%9F%B3


static public String[] toMPS2PinyinStringArray(char ch)

转换为注音符号拼音:http://zh.wikipedia.org/zh-cn/%E6%B3%A8%E9%9F%B3%E7%AC%A6%E8%99%9F


static public String[] toYalePinyinStringArray(char ch)

转换为耶

原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_28909.html