B4A Pinyin - Chinese to Pinyin (B4A拼音)
Pinyin4j is a popular Java library supporting conversion between Chinese characters and most popular Pinyin systems. This wrapper was requested here.
I based my wrapper on a github project found here.
Kudos to the original authors.
Many thanks also to @xky for helping with the testing of the wrapper
Usage:
Add the attached libraries in your Additional Library folder. Make sure to refresh the library pane in B4A. Then take also look at the sample-project attached. I have also attached the java-wrapper if someone wants to modify it.
This is a useful link for further information:
http://pinyin4j.sourceforge.net/pin.../pinyin4j/format/HanyuPinyinOutputFormat.html
Note: methods present in previous versions of this wrapper are still included for compatibility. However, they should be considered Deprecated and you should now use the new method ConvertToPinyin().
Note2: the old method converterToFirstSpell() can still be useful if you need a pinyin output in an abbreviated format.
Note3: this library works fine with B4J as well.
B4Apinyin
Author: moster67/Mikael Osterhed
Version: 1.3
[*]Pinyin
Fields:
Hope it will turn out to be useful (I guess mostly for our fellow Chinese B4A-users).
Pinyin4j is a popular Java library supporting conversion between Chinese characters and most popular Pinyin systems. This wrapper was requested here.
I based my wrapper on a github project found here.
Kudos to the original authors.
Many thanks also to @xky for helping with the testing of the wrapper
Usage:
Add the attached libraries in your Additional Library folder. Make sure to refresh the library pane in B4A. Then take also look at the sample-project attached. I have also attached the java-wrapper if someone wants to modify it.
This is a useful link for further information:
http://pinyin4j.sourceforge.net/pin.../pinyin4j/format/HanyuPinyinOutputFormat.html
Note: methods present in previous versions of this wrapper are still included for compatibility. However, they should be considered Deprecated and you should now use the new method ConvertToPinyin().
Note2: the old method converterToFirstSpell() can still be useful if you need a pinyin output in an abbreviated format.
Note3: this library works fine with B4J as well.
B4Apinyin
Author: moster67/Mikael Osterhed
Version: 1.3
[*]Pinyin
Fields:
- DO_NOT_USE_VCHARTYPE As Int
- LOWERCASE As Int
- UPPERCASE As Int
- WITHOUT_TONE As Int
- WITH_TONE_MARK As Int
- WITH_TONE_NUMBER As Int
- WITH_U_AND_COLON As Int
- WITH_U_UNICODE As Int
- WITH_V As Int
- ConvertToPinyin (chinese As String, caseType As Int, toneType As Int, vCharType As Int) As String
ConvertToPinyin() requires four parameters.
1) chinese hologram (word) to convert (String)
2) caseType to apply. Can be LOWERCASE or UPPERCASE
3) toneType to apply. Can be WITHOUT_TONE, WITH_TONE_MARK or WITH_TONE_NUMBER
4) vCharType to apply. Can be WITH_U_UNICODE, WITH_U_AND_COLON, WITH_V or DO_NOT_USE_VCHARTYPE
Note: combinations of toneType WITH_TONE_MARK and vCharTypes WITH_U_AND_COLON and WITH_V do not work.
This is intentional and will produce a blank output.
Example usage:
Private PinyinObject As Pinyin
Dim str2 As String = PinyinObject.convertToPinyin("壮丽",PinyinObject.LOWERCASE,PinyinObject.WITH_TONE_MARK, PinyinObject.WITH_U_UNICODE) - HanZiToPinYinWIthToneMark (hanzi As Char) As String
Deprecated. Included only for compatibility reasons for previous versions of this wrapper.
Please use the method ConvertToPinyin() instead. - converterToFirstSpell (chines As String) As String
Deprecated. Included only for compatibility reasons for previous versions of this wrapper.
Please use the method ConvertToPinyin() instead. - converterToSpell (chines As String) As String
Deprecated. Included only for compatibility reasons for previous versions of this wrapper.
Please use the method ConvertToPinyin() instead.
Hope it will turn out to be useful (I guess mostly for our fellow Chinese B4A-users).
Attachments
Last edited: