*
*
* Special Note: If the return contains "none0", that means that
* Chinese character is in Unicode CJK talbe, however, it has not
* pronounciation in Chinese. This interface will be removed in next
* release.
*
* @param str
* A given string contains Chinese characters
* @param outputFormat
* Describes the desired format of returned Hanyu Pinyin string
* @param seperater
* The string is appended after a Chinese character (excluding
* the last Chinese character at the end of sentence). Note!
* Seperater will not appear after a non-Chinese character
* @return a String identical to the original one but all recognizable
* Chinese characters are converted into main (first) Hanyu Pinyin
* representation
*
* @deprecated DO NOT use it again because the first retrived pinyin string
* may be a wrong pronouciation in a certain sentence context.
* This interface will be removed in next release.
*/
static public String toHanyuPinyinString(String str,
HanyuPinyinOutputFormat outputFormat, String seperater)
throws BadHanyuPinyinOutputFormatCombination
{
StringBuffer resultPinyinStrBuf = new StringBuffer();
for (int i = 0; i < str.length(); i++)
{
String mainPinyinStrOfChar = getFirstHanyuPinyinString(str.charAt(i), outputFormat);
if (null != mainPinyinStrOfChar)
{
resultPinyinStrBuf.append(mainPinyinStrOfChar);
if (i != str.length() - 1)
{ // avoid appending at the end
resultPinyinStrBuf.append(seperater);
}
} else
{
resultPinyinStrBuf.append(str.charAt(i));
}
}
return resultPinyinStrBuf.toString();
}
/**
* Get the first Hanyu Pinyin of a Chinese character This function will
* be removed in next release.
*
* @param ch
* The given Unicode character
* @param outputFormat
* Describes the desired format of returned Hanyu Pinyin string
* @return Return the first Hanyu Pinyin of given Chinese character; return
* null if the input is not a Chinese character
*
* @deprecated DO NOT use it again because the first retrived pinyin string
* may be a wrong pronouciation in a certain sentence context.
* This function will be removed in next release.
*/
static private String getFirstHanyuPinyinString(char ch,
HanyuPinyinOutputFormat outputFormat)
throws BadHanyuPinyinOutputFormatCombination
{
String[] pinyinStrArray = getFormattedHanyuPinyinStringArray(ch, outputFormat);
if ((null != pinyinStrArray) && (pinyinStrArray.length > 0))
{
return pinyinStrArray[0];
} else
{
return null;
}
}
// ! Hidden constructor
private PinyinHelper()
{
}
}
拼音系统列表如下:
[java]
/**
* This file is part of pinyin4j (http://sourceforge.net/projects/pinyin4j/)
* and distributed under GNU GENERAL PUBLIC LICENSE (GPL).
*
* pinyin4j is free software; you can redistribute it and/or modify
* it under the terms of t