public class Pinyin4jEngine extends Object implements PinyinEngine
pinyin4j(http://sourceforge.net/projects/pinyin4j)封装。
引入:
<dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>2.5.1</version> </dependency>
Constructor and Description |
---|
Pinyin4jEngine()
构造
|
Pinyin4jEngine(net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat format)
构造
|
Modifier and Type | Method and Description |
---|---|
String |
getPinyin(char c)
如果c为汉字,则返回大写拼音;如果c不是汉字,则返回String.valueOf(c)
|
String |
getPinyin(String str,
String separator)
获取字符串对应的完整拼音,非中文返回原字符
|
void |
init(net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat format)
初始化
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFirstLetter, getFirstLetter
public Pinyin4jEngine()
public Pinyin4jEngine(net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat format)
format
- 格式public void init(net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat format)
format
- 格式public String getPinyin(char c)
PinyinEngine
getPinyin
in interface PinyinEngine
c
- 任意字符,汉字返回拼音,非汉字原样返回public String getPinyin(String str, String separator)
PinyinEngine
getPinyin
in interface PinyinEngine
str
- 字符串separator
- 拼音之间的分隔符Copyright © 2024. All rights reserved.