如何获取汉字的拼音

来源:互联网 发布:js 变量命名规范 编辑:程序博客网 时间:2024/04/24 19:01

一)本文的目的:
本文主要介绍如何调用系统库函数获取汉字的拼音。

 

二)具体实现:
主要用到类CPtiEngine及对应的库ptiengine.lib,头文件#include <ptiengine.h>

 

1)打开字库
TBool CFindUtilChinese::OpenT9InterfaceL(TLanguage aLanguage)
{
    if (!iPtiEngine)
    {
         iPtiEngine = CPtiEngine::NewL();
    }
    if (aLanguage != iLanguage)
    {
         iPtiEngine->ActivateLanguageL(iLanguage);
         iPtiEngine->EnableToneMarks(EFalse);
    }
    return ETrue;
}

 

2)关闭字库
void CFindUtilChinese::CloseT9InterfaceL()
{
    iLanguage = ELangTest;
    iPtiEngine->CloseCurrentLanguageL();
}

 

3)调用CPtiEngine::GetSpelling (TUint16 aInput, TDes &aOutput, TPtiSpelling aType)

//函数的SDK介绍
IMPORT_C TInt CPtiEngine::GetSpelling  (  TUint16  aInput, 
                                        TDes &  aOutput, 
                                        TPtiSpelling  aType
                                        )  

Returns alternate spelling for given character.


Parameters:
aInput  a character to be converted to requested spelling. 
aOutput  output will be stored to this descriptor. 
aType  spelling type 

Returns:
KErrNone if operation was successful, KErrNotSupported if requested spelling type is not supported. 

原创粉丝点击