#include <sqlite3.h>
Go to the source code of this file.
Defines | |
#define | PINYIN_MAX_LENGTH 9 |
Maximum space that PinYin requires. | |
#define | ZHUYIN_MAX_LENGTH 13 |
Maximum space that ZhuYin requires. | |
#define | ZHUYIN_SYMBOL_COUNT ZHUYIN_SYMBOL_NEUTRAL + 1 |
Total number of support ZhuYin symbols. | |
Typedefs | |
typedef gunichar | ZhuYin_Symbol |
ZhuYin symbol. | |
typedef char | ZhuYin |
Pronunciation in ZhuYin UTF-8 string. | |
typedef char | PinYin |
Pronunciation in PinYin UTF-8 string. | |
Enumerations | |
enum | ZhuYin_Symbol_Id { ZHUYIN_INVALID_SYMBOL = -1, ZHUYIN_SYMBOL_B, ZHUYIN_SYMBOL_P, ZHUYIN_SYMBOL_M, ZHUYIN_SYMBOL_F, ZHUYIN_SYMBOL_D, ZHUYIN_SYMBOL_T, ZHUYIN_SYMBOL_N, ZHUYIN_SYMBOL_L, ZHUYIN_SYMBOL_G, ZHUYIN_SYMBOL_K, ZHUYIN_SYMBOL_H, ZHUYIN_SYMBOL_J, ZHUYIN_SYMBOL_Q, ZHUYIN_SYMBOL_X, ZHUYIN_SYMBOL_ZH, ZHUYIN_SYMBOL_CH, ZHUYIN_SYMBOL_SH, ZHUYIN_SYMBOL_R, ZHUYIN_SYMBOL_Z, ZHUYIN_SYMBOL_C, ZHUYIN_SYMBOL_S, ZHUYIN_SYMBOL_I, ZHUYIN_SYMBOL_U, ZHUYIN_SYMBOL_U_DIAERESIS, ZHUYIN_SYMBOL_A, ZHUYIN_SYMBOL_O, ZHUYIN_SYMBOL_E, ZHUYIN_SYMBOL_E_CIRCUMFLEX, ZHUYIN_SYMBOL_AI, ZHUYIN_SYMBOL_EI, ZHUYIN_SYMBOL_AO, ZHUYIN_SYMBOL_OU, ZHUYIN_SYMBOL_AN, ZHUYIN_SYMBOL_EN, ZHUYIN_SYMBOL_ANG, ZHUYIN_SYMBOL_ENG, ZHUYIN_SYMBOL_ER, ZHUYIN_SYMBOL_1, ZHUYIN_SYMBOL_2, ZHUYIN_SYMBOL_3, ZHUYIN_SYMBOL_4, ZHUYIN_SYMBOL_NEUTRAL } |
Enumeration of ZhuYin symbols. More... | |
enum | PinYin_Accent_Format { PINYIN_ACCENT_ALWAYS, PINYIN_ACCENT_ORIGINAL, PINYIN_ACCENT_UNIHAN, PINYIN_ACCENT_TRAILING, PINYIN_ACCENT_INPUT_METHOD, PINYIN_ACCENT_NONE } |
Enumeration of PinYin accent (not tone mark) handling modes. More... | |
enum | ZhuYin_ToneMark_Format { ZHUYIN_TONEMARK_ALWAYS, ZHUYIN_TONEMARK_ORIGINAL, ZHUYIN_TONEMARK_INPUT_METHOD, ZHUYIN_TONEMARK_NUMERICAL } |
Enumeration of ZhuYin tone mark handling. More... | |
Functions | |
PinYin * | pinYin_new (const char *pinYin_str) |
New a PinYin instance. | |
guint | pinYin_strip_tone (PinYin *pinYin) |
Strip the tone mark of PinYin and return the tone Id. | |
void | pinYin_add_tone (PinYin *pinYin, guint tone, gboolean useTrailNumber) |
Add the tone mark to pinYin. | |
PinYin * | pinYin_convert_accent_format (const PinYin *pinYin, PinYin_Accent_Format toFormat, gboolean useTrailNumber) |
Convert a PinYin to new accent formatReturn a newly allocated PinYin instance which contains the converted content. | |
ZhuYin * | pinYin_to_zhuYin (const PinYin *pinYin, ZhuYin_ToneMark_Format toFormat) |
PinYin to ZhuYin. | |
ZhuYin * | zhuYin_new (const char *zhuYin_str) |
New a ZhuYin instance. | |
guint | zhuYin_strip_tone (ZhuYin *zhuYin) |
Strip tone mark of ZhuYin. | |
void | zhuYin_add_tone (ZhuYin *zhuYin, guint tone, ZhuYin_ToneMark_Format toFormat) |
Add the tone mark to zhuYin. | |
ZhuYin * | zhuYin_convert_toneMark_format (const ZhuYin *zhuYin, ZhuYin_ToneMark_Format toFormat) |
Convert zhuyin to another tone mark format. | |
PinYin * | zhuYin_to_pinYin (const ZhuYin *zhuYin, PinYin_Accent_Format toFormat, gboolean useTrailNumber) |
ZhuYin to PinYin. | |
ZhuYin_Symbol | zhuYin_Symbol_from_id (ZhuYin_Symbol_Id id) |
Return the ZhuYin symbol by its Id. | |
ZhuYin_Symbol_Id | zhuYin_Symbol_get_id (ZhuYin_Symbol zSym) |
Return the Id of a ZhuYin symbol. | |
gboolean | zhuYin_Symbol_is_initial (ZhuYin_Symbol zSym) |
Whether the zhuYin symbol is an initial. | |
gboolean | zhuYin_Symbol_is_medial (ZhuYin_Symbol zSym) |
Whether the zhuYin symbol is an medial. | |
gboolean | zhuYin_Symbol_is_final (ZhuYin_Symbol zSym) |
Whether the zhuYin symbol is an final. | |
gboolean | zhuYin_Symbol_is_tone (ZhuYin_Symbol zSym) |
Whether the zhuYin symbol is either a toneMark or number which indicates the tone. | |
guint | zhuYin_Symbol_to_toneMark_id (ZhuYin_Symbol zSym) |
Return the tone id of given tone mark. | |
ZhuYin_Symbol | zhuYin_Symbol_from_toneMark_id (guint toneMark_id) |
Return the tone mark of given tone id. | |
void | pinYin_convert_accent_format_scalar_func (sqlite3_context *context, int argc, sqlite3_value **argv) |
PinYin convert accent format scalar function for SQL command call. | |
void | pinYin_to_zhuYin_scalar_func (sqlite3_context *context, int argc, sqlite3_value **argv) |
PinYin to ZhuYin converting scalar function for SQL command call. | |
void | zhuYin_convert_toneMark_format_scalar_func (sqlite3_context *context, int argc, sqlite3_value **argv) |
ZhuYin convert accent format scalar function for SQL command call. | |
void | zhuYin_to_pinYin_scalar_func (sqlite3_context *context, int argc, sqlite3_value **argv) |
ZhuYin to PinYin converting scalar function for SQL command call. | |
Variables | |
const ZhuYin_Symbol | ZHUYIN_SYMBOL_LIST [] |
An array of ZhuYin symbols. |
This header file lists the functions for PinYin and ZhuYin processing, such as conversion between HanYu pinyin conversion C functions, and corresponding SQL scalar functions.
Note that PinYin is represented as uppercase, which is same with kMandarin in Unihan.
enum PinYin_Accent_Format |
Enumeration of PinYin accent (not tone mark) handling modes.
There are two PinYin symbols with accents, diaeresis U (Ü,ㄩ), and circumflex E (Ê,ㄝ) . As the their pronunciations are different from U and E.
In Romanization of Chinese (ISO 7098:1991), under certain circumstances, accents can be omitted, such as JÜ -> JU , QÜ ->QU. This is adopted in PRC education system. Use PINYIN_ACCENT_ORIGINAL for this purpose.
Unihan project does not have circumflex E (Ê), the other is same with ISO 7098. Use PINYIN_ACCENT_UNIHAN for Unihan project.
Because Ü is not on most of the keyboards, there are various ways to represent Ü. For example, CEDICT use U: (PINYIN_ACCENT_TRAILING); while most of Chinese input method use V as substitute (PINYIN_ACCENT_INPUT_METHOD).
In English documents such as passport, the accent are usually ignores, use PINYIN_ACCENT_NONE for this purpose.
Preserving accents unconditionally makes conversion and education easier, use PINYIN_ACCENT_ALWAYS for this purpose.
Note that this enumeration is not for the pinyin tone mark. See pinYin_convert_accent_format() pinyin tone mark handling.
enum ZhuYin_Symbol_Id |
Enumeration of ZhuYin symbols.
This enumeration lists the ZhuYin symbols, including the symbols for tone mark. Corresponding PinYin phonemes can also be located using these Ids.
pinYin_phoneme_get_id()
Enumeration of ZhuYin tone mark handling.
Originally, the neutral (fifth) tone mark of zhuyin is put in the front, while the first tone mark is omitted. Use ZHUYIN_TONEMARK_ORIGINAL for this.
However, for Zhuyin based input method, the neutral is put in the back. Use ZHUYIN_TONEMARK_INPUT_METHOD for this.
If preserving tonemark is desireable, then use ZHUYIN_TONEMARK_ALWAYS, in which the first tone is not omitted, otherwise is same with ZHUYIN_TONEMARK_INPUT_METHOD.
If numerical tone mark is desired, use ZHUYIN_TONEMARK_NUMERICAL.
void pinYin_add_tone | ( | PinYin * | pinYin, | |
guint | tone, | |||
gboolean | useTrailNumber | |||
) |
Add the tone mark to pinYin.
The result will be stored in pinYin, so backup it with strdup() or g_strdup() to keep the original.
pinYin | the pinYin instance to be processed. | |
tone | the tone to be added. | |
useTrailNumber | TRUE trailing number is preferred, FALSE to use traditional tonemark. |
PinYin* pinYin_convert_accent_format | ( | const PinYin * | pinYin, | |
PinYin_Accent_Format | toFormat, | |||
gboolean | useTrailNumber | |||
) |
Convert a PinYin to new accent formatReturn a newly allocated PinYin instance which contains the converted content.
Note: use g_free to free the newly allocated instance.
pinYin | the PinYin to be converted. | |
toFormat | the PinYin accent mode to be converted to. | |
useTrailNumber | TRUE trailing number is preferred, FALSE to use traditional tonemark. |
void pinYin_convert_accent_format_scalar_func | ( | sqlite3_context * | context, | |
int | argc, | |||
sqlite3_value ** | argv | |||
) |
PinYin convert accent format scalar function for SQL command call.
This function is meant to be called by sqlite3_create_function() and used in SQL command. Do not use it directly.
context | The sqlite3_context. | |
argc | Number of argument expected. | |
argv | Arguments for this scalar function . |
PinYin* pinYin_new | ( | const char * | pinYin_str | ) |
New a PinYin instance.
This function allocate a new PinYin instance. Non pinYin_str will be copied to the newly allocated PinYin instance and converted to uppercase. Note that the PinYin instance only hold PINYIN_MAX_LENGTH bytes, including the EOL ('') character. Longer pinYin will be truncated.
Note: use g_free to free the newly allocated instance.
pinYin_str | the PinYin in string, NULL for blank instance. |
guint pinYin_strip_tone | ( | PinYin * | pinYin | ) |
Strip the tone mark of PinYin and return the tone Id.
This function strips the tone mark of pinYin and return the id (0 to 5) of stripped tone mark. The result will be stored in pinYin, so backup it with strdup() or g_strdup() to keep the original.
Note that 5 will be returned if pinYin does not have any tone mark, as it usually implies that pinYin is in fifth tone.
pinYin | the pinYin instance to be stripped. |
ZhuYin* pinYin_to_zhuYin | ( | const PinYin * | pinYin, | |
ZhuYin_ToneMark_Format | toFormat | |||
) |
PinYin to ZhuYin.
pinYin | the PinYin to be converted. | |
toFormat | the ZhuYin tone mark mode. |
void pinYin_to_zhuYin_scalar_func | ( | sqlite3_context * | context, | |
int | argc, | |||
sqlite3_value ** | argv | |||
) |
PinYin to ZhuYin converting scalar function for SQL command call.
This function is meant to be called by sqlite3_create_function() and used in SQL command. Do not use it directly.
context | The sqlite3_context. | |
argc | Number of argument expected. | |
argv | Arguments for this scalar function . |
void zhuYin_add_tone | ( | ZhuYin * | zhuYin, | |
guint | tone, | |||
ZhuYin_ToneMark_Format | toFormat | |||
) |
Add the tone mark to zhuYin.
The result will be stored in zhuYin, so backup it with strdup() or g_strdup() to keep the original.
zhuYin | the zhuYin instance to be processed. | |
tone | the tone to be added. | |
toFormat | the ZhuYin tone mark mode to be converted to. |
ZhuYin* zhuYin_convert_toneMark_format | ( | const ZhuYin * | zhuYin, | |
ZhuYin_ToneMark_Format | toFormat | |||
) |
Convert zhuyin to another tone mark format.
Note: use g_free to free the newly allocated instance.
zhuYin | the ZhuYin to be converted. | |
toFormat | the ZhuYin tone mark mode to be converted to. |
void zhuYin_convert_toneMark_format_scalar_func | ( | sqlite3_context * | context, | |
int | argc, | |||
sqlite3_value ** | argv | |||
) |
ZhuYin convert accent format scalar function for SQL command call.
This function is meant to be called by sqlite3_create_function() and used in SQL command. Do not use it directly.
context | The sqlite3_context. | |
argc | Number of argument expected. | |
argv | Arguments for this scalar function . |
ZhuYin* zhuYin_new | ( | const char * | zhuYin_str | ) |
New a ZhuYin instance.
This function allocate a new ZhuYin instance. Non-NULL zhuYin_str will be copied to the new ZhuYin instance and converted to uppercase. Note that the ZhuYin instance only holds ZHUYIN_MAX_LENGTH bytes, including the EOL ('') character. Longer zhuYin will be truncated.
Note: use g_free to free the newly allocated instance.
zhuYin_str | the ZhuYin in string, NULL for blank instance. |
guint zhuYin_strip_tone | ( | ZhuYin * | zhuYin | ) |
Strip tone mark of ZhuYin.
This function strips the tone mark of zhuYin and return the id (1 to 5) of stripped tone mark. Tone mark 1 will be returned if zhuYin does not have any tone mark. The result will be stored in zhuYin, so backup it with g_strdup() to keep the original.
Note that 1 will be returned if zhuYin does not have any tone mark, as it usually implies that zhuYin is in first tone.
zhuYin | the ZhuYin instance to be stripped. |
ZhuYin_Symbol zhuYin_Symbol_from_id | ( | ZhuYin_Symbol_Id | id | ) |
Return the ZhuYin symbol by its Id.
id | ZhuYin symbol Id. |
ZhuYin_Symbol zhuYin_Symbol_from_toneMark_id | ( | guint | toneMark_id | ) |
Return the tone mark of given tone id.
toneMark_id | toneMark_id. |
ZhuYin_Symbol_Id zhuYin_Symbol_get_id | ( | ZhuYin_Symbol | zSym | ) |
Return the Id of a ZhuYin symbol.
zSym | ZhuYin symbol. |
gboolean zhuYin_Symbol_is_final | ( | ZhuYin_Symbol | zSym | ) |
Whether the zhuYin symbol is an final.
zSym | ZhuYin symbol. |
gboolean zhuYin_Symbol_is_initial | ( | ZhuYin_Symbol | zSym | ) |
Whether the zhuYin symbol is an initial.
zSym | ZhuYin symbol. |
gboolean zhuYin_Symbol_is_medial | ( | ZhuYin_Symbol | zSym | ) |
Whether the zhuYin symbol is an medial.
zSym | ZhuYin symbol. |
gboolean zhuYin_Symbol_is_tone | ( | ZhuYin_Symbol | zSym | ) |
Whether the zhuYin symbol is either a toneMark or number which indicates the tone.
zSym | ZhuYin symbol. |
guint zhuYin_Symbol_to_toneMark_id | ( | ZhuYin_Symbol | zSym | ) |
Return the tone id of given tone mark.
zSym | ZhuYin symbol. |
PinYin* zhuYin_to_pinYin | ( | const ZhuYin * | zhuYin, | |
PinYin_Accent_Format | toFormat, | |||
gboolean | useTrailNumber | |||
) |
ZhuYin to PinYin.
zhuYin | the ZhuYin to be converted. | |
toFormat | the PinYin accent mode. | |
useTrailNumber | TRUE trailing number is preferred, FALSE to use traditional tonemark. |
void zhuYin_to_pinYin_scalar_func | ( | sqlite3_context * | context, | |
int | argc, | |||
sqlite3_value ** | argv | |||
) |
ZhuYin to PinYin converting scalar function for SQL command call.
This function is meant to be called by sqlite3_create_function() and used in SQL command. Do not use it directly.
context | The sqlite3_context. | |
argc | Number of argument expected. | |
argv | Arguments for this scalar function . |