本文整理汇总了C++中CCnvCharacterSetConverter::ConvertToUnicode方法的典型用法代码示例。如果您正苦于以下问题:C++ CCnvCharacterSetConverter::ConvertToUnicode方法的具体用法?C++ CCnvCharacterSetConverter::ConvertToUnicode怎么用?C++ CCnvCharacterSetConverter::ConvertToUnicode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCnvCharacterSetConverter
的用法示例。
在下文中一共展示了CCnvCharacterSetConverter::ConvertToUnicode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CT_ISO2022JP1_2::TestSplittingConvertingFromUnicodeToIso2022Jp(
CCnvCharacterSetConverter& aCharacterSetConverter,
TInt aMaximumLengthLowerLimit,
TInt aMaximumLengthUpperLimit,
TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit,
const TDesC8& aExpectedFirstPartOfIso2022Jp,
const TDesC8& aExpectedSecondPartOfIso2022Jp,
const TDesC16& aOriginalUnicode)
{
INFO_PRINTF1(_L(" TestTruncatedConversionFromUnicodeToIso2022Jp "));
test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
test(aMaximumLengthUpperLimit<=KBufferLength);
TUint8 iso2022JpBuffer[KBufferLength];
for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
{
TPtr8 generatedFirstPartOfIso2022Jp(iso2022JpBuffer, i);
test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfIso2022Jp, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
test(generatedFirstPartOfIso2022Jp==aExpectedFirstPartOfIso2022Jp);
TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp;
test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
test(generatedSecondPartOfIso2022Jp==aExpectedSecondPartOfIso2022Jp);
TInt state=CCnvCharacterSetConverter::KStateDefault;
TBuf16<KBufferLength> generatedUnicode;
test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfIso2022Jp, state)==0);
TBuf16<KBufferLength> generatedSecondPartOfUnicode;
test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfIso2022Jp, state)==0);
generatedUnicode.Append(generatedSecondPartOfUnicode);
test(generatedUnicode==aOriginalUnicode);
}
}
示例2: generatedFirstPartOfEucJpPacked
/**
@SYMTestCaseID SYSLIB-CHARCONV-CT-0536
@SYMTestCaseDesc Splitting and converting from Unicode to EucJpPacked test
@SYMTestPriority Medium
@SYMTestActions Tests for conversion after splitting, from Unicode to EucJpPacked and back to Unicode
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ0000
*/
void CT_EUCJP_PACKED_2::TestSplittingConvertingFromUnicodeToEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfEucJpPacked, const TDesC8& aExpectedEucJpPacked, const TDesC16& aOriginalUnicode)
{
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0536 "));
test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
test(aMaximumLengthUpperLimit<=KBufferLength);
TUint8 eucJpPackedBuffer[KBufferLength];
for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
{
TPtr8 generatedFirstPartOfEucJpPacked(eucJpPackedBuffer, i);
test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfEucJpPacked, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
test(generatedFirstPartOfEucJpPacked==aExpectedEucJpPacked.Left(aExpectedLengthOfFirstPartOfEucJpPacked));
TBuf8<KBufferLength> generatedSecondPartOfEucJpPacked;
test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfEucJpPacked, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
test(generatedSecondPartOfEucJpPacked==aExpectedEucJpPacked.Mid(aExpectedLengthOfFirstPartOfEucJpPacked));
TInt state=CCnvCharacterSetConverter::KStateDefault;
TBuf16<KBufferLength> generatedUnicode;
test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfEucJpPacked, state)==0);
test(state==CCnvCharacterSetConverter::KStateDefault);
TBuf16<KBufferLength> generatedSecondPartOfUnicode;
test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfEucJpPacked, state)==0);
test(state==CCnvCharacterSetConverter::KStateDefault);
generatedUnicode.Append(generatedSecondPartOfUnicode);
test(generatedUnicode==aOriginalUnicode);
}
}
示例3:
/**
@SYMTestCaseID SYSLIB-CHARCONV-CT-0537
@SYMTestCaseDesc Tests for truncated conversion from EucJpPacked to Unicode
@SYMTestPriority Medium
@SYMTestActions Tests for truncated conversion from EucJpPacked to Unicode and back to EucJpPacked
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ0000
*/
void CT_EUCJP_PACKED_2::TestTruncatedConversionToUnicodeFromEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalEucJpPacked)
{
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0537 "));
for (TInt i=aOriginalEucJpPacked.Length(); i>=3; --i) // 3 is the length of GBK's longest multi-byte characters
{
TInt state=CCnvCharacterSetConverter::KStateDefault;
TBuf16<KBufferLength> generatedUnicode;
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalEucJpPacked.Left(i), state);
test(returnValue>=0);
TBuf16<KBufferLength> generatedsecondPartOfUnicode;
test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalEucJpPacked.Mid(i-returnValue), state)==0);
generatedUnicode.Append(generatedsecondPartOfUnicode);
test(generatedUnicode==aExpectedUnicode);
}
}
示例4: InitOptions
void CRhodesAppView::InitOptions()
{
char* slash = "";
char* options_page = callGetOptionsPage();
if (!options_page) {
options_page = "";
} else if ( (*options_page!='/')&&(*options_page!='\\') ) {
slash = "/";
}
int len = strlen(get_home_url())+strlen(slash)+strlen(options_page);
char* sp = (char*) malloc(len+1);
sprintf(sp,"%s%s%s",get_home_url(),slash,options_page);
RFs session;
User::LeaveIfError(session.Connect());
CCnvCharacterSetConverter *converter = CCnvCharacterSetConverter::NewL();
converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, session);
TPtrC8 ptr((const unsigned char*)sp);
int state = CCnvCharacterSetConverter::KStateDefault;
converter->ConvertToUnicode(iOptionsPage, ptr, state);
session.Close();
free(sp);
}
示例5: ConvertToUnicode
void ConvertToUnicode(RFs session, TDes16& aUnicode, const char *str)
{
CCnvCharacterSetConverter *converter = CCnvCharacterSetConverter::NewL();
converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, session);
TPtrC8 ptr((const unsigned char*)str);
int state = CCnvCharacterSetConverter::KStateDefault;
converter->ConvertToUnicode(aUnicode, ptr, state);
}
示例6: generatedFirstPartOfUnicode
void CT_ISO2022JP1_2::TestSplittingConvertingToUnicodeFromIso2022Jp(
CCnvCharacterSetConverter& aCharacterSetConverter,
TInt aMaximumLengthLowerLimit,
TInt aMaximumLengthUpperLimit,
TInt aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit,
TInt aExpectedLengthOfFirstPartOfUnicode,
const TDesC16& aExpectedUnicode,
const TDesC8& aOriginalIso2022Jp)
{
INFO_PRINTF1(_L(" TestSplittingConvertingToUnicodeFromIso2022Jp "));
test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
test(aMaximumLengthUpperLimit<=KBufferLength);
TUint16 unicodeBuffer[KBufferLength];
for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
{
TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i);
TInt state=CCnvCharacterSetConverter::KStateDefault;
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalIso2022Jp, state);
test(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode));
test(returnValue==aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit);
TBuf16<KBufferLength> generatedSecondPartOfUnicode;
test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalIso2022Jp.Right(aExpectedNumberOfIso2022JpBytesNotConvertedAtSplit), state)==0);
test(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode));
TBuf8<KBufferLength> generatedIso2022Jp;
test(aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, generatedFirstPartOfUnicode)==0);
TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp;
test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, generatedSecondPartOfUnicode)==0);
generatedIso2022Jp.Append(generatedSecondPartOfIso2022Jp);
TBuf16<KBufferLength> regeneratedUnicode;
state=CCnvCharacterSetConverter::KStateDefault;
test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, generatedIso2022Jp, state)==0);
// test(regeneratedUnicode==aExpectedUnicode);
state=CCnvCharacterSetConverter::KStateDefault;
test(aCharacterSetConverter.ConvertToUnicode(regeneratedUnicode, aOriginalIso2022Jp, state)==0);
test(regeneratedUnicode==aExpectedUnicode);
}
}
示例7: ConvertFromPythonString
void CLocaLogicImpl::ConvertFromPythonString(TDes& aBuf, PyObject* aString)
{
aBuf.Zero();
if (PyString_Check(aString)) {
TInt state=CCnvCharacterSetConverter::KStateDefault;
TInt len=PyString_Size(aString);
if (len > aBuf.MaxLength()) len=aBuf.MaxLength();
iCC->ConvertToUnicode(aBuf, TPtrC8((TUint8*)PyString_AsString(aString),
len), state);
} else if (PyUnicode_Check(aString)) {
TInt len=PyUnicode_GetSize(aString)/2;
if (len > aBuf.MaxLength()) len=aBuf.MaxLength();
aBuf=TPtrC((TUint16*)PyUnicode_AsUnicode(aString), len);
}
}
示例8: ay_sys_getstr
TFileName ay_sys_getstr(const unsigned char *str, unsigned long length)
{
CCnvCharacterSetConverter *aCharacterSetConverter = CCnvCharacterSetConverter::NewL();
RFs aFileServerSession;
TUint aForeignCharacterSet = KCharacterSetIdentifierAscii;
// check to see if the character set is supported - if not then leave
if (aCharacterSetConverter->PrepareToConvertToOrFromL(aForeignCharacterSet,
aFileServerSession) != CCnvCharacterSetConverter::EAvailable)
User::Leave(KErrNotSupported);
// Create a small output buffer
TBuf16<20> outputBuffer;
TFileName endBuffer;
// Create a buffer for the unconverted text - initialised with the input descriptor
TPtrC8 remainderOfForeignText(str, length);
// Create a "state" variable and initialise it with CCnvCharacterSetConverter::KStateDefault
// After initialisation the state variable must not be tampered with.
// Simply pass into each subsequent call of ConvertToUnicode()
TInt state=CCnvCharacterSetConverter::KStateDefault;
for(;;) // conversion loop
{
// Start conversion. When the output buffer is full, return the number
// of characters that were not converted
const TInt returnValue=aCharacterSetConverter->ConvertToUnicode(outputBuffer, remainderOfForeignText, state);
// check to see that the descriptor isn�t corrupt - leave if it is
if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput)
User::Leave(KErrCorrupt);
else if (returnValue<0) // future-proof against "TError" expanding
User::Leave(KErrGeneral);
// Do something here to store the contents of the output buffer.
// Finish conversion if there are no unconverted
// characters in the remainder buffer
endBuffer += outputBuffer;
if (returnValue==0)
break;
// Remove converted source text from the remainder buffer.
// The remainder buffer is then fed back into loop
remainderOfForeignText.Set(remainderOfForeignText.Right(returnValue));
}
delete aCharacterSetConverter;
return endBuffer;
}
示例9: remainderOfEucJpPacked
/**
@SYMTestCaseID SYSLIB-CHARCONV-CT-0539
@SYMTestCaseDesc Conversion of bad EucJpPacked format to Unicode test
@SYMTestPriority Medium
@SYMTestActions Tests to convert Ill formed EucJpPacked input to Unicode.
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ0000
*/
void CT_EUCJP_PACKED_2::TestIsIllFormedEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC8& aEucJpPacked)
{
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0539 "));
TBuf16<50> generatedUnicode;
TInt state=CCnvCharacterSetConverter::KStateDefault;
TPtrC8 remainderOfEucJpPacked(aEucJpPacked);
TInt lastReturnValue=KMaxTInt;
FOREVER
{
const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, remainderOfEucJpPacked, state);
if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput)
{
break;
}
test(returnValue>0);
test(returnValue<lastReturnValue);
lastReturnValue=returnValue;
remainderOfEucJpPacked.Set(remainderOfEucJpPacked.Right(returnValue));
}
}
示例10: ConvertToUnicodeFromGBK
//
//将中文字符转换成Unicode
HBufC16* CCommonUtils::ConvertToUnicodeFromGBK(const TText8* aStr)
{
CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();
if( converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierGbk,CEikonEnv::Static()->FsSession()) != CCnvCharacterSetConverter::EAvailable)
{
delete converter;
return NULL;
}
//TText8 *str = (TText8*)"诺基亚7650C";
TInt state= CCnvCharacterSetConverter::KStateDefault;
TPtrC8 source( aStr );
HBufC* ret = HBufC::NewLC( source.Length() );
TPtr16 ptr = ret->Des();
converter->ConvertToUnicode(ptr, source, state);
CleanupStack::Pop(ret);
return ret;
}
示例11: ToUnicodeL
// ============================================================================
// CWidgetUIConfigHandler::ToUnicodeL
// Utility to bundle transcoding to unicode steps.
//
// @since 3.1
// @param aEncoding input buffer encoding
// @param aUnicodeSizeMultiplier how many bytes of input make one unicode char
// @param aInBuf input data in encoding
// @param aOutBuf malloc'ed output buf, caller takes ownership
// @param aFileSession CCnvCharacterSetConverter requires it
// ============================================================================
//
void CWidgetUIConfigHandler::ToUnicodeL( TInt aEncoding,
TInt aUnicodeSizeMultiplier,
TPtrC8 aInBuf, HBufC16** aOutBuf,
RFs& aFileSession )
{
*aOutBuf = NULL;
// outbuf sizing and alloction
HBufC16* outBuf = HBufC16::NewLC(aUnicodeSizeMultiplier * aInBuf.Length());
TPtr16 outPtr = outBuf->Des();
// convert to unicode
CCnvCharacterSetConverter* charConv = CCnvCharacterSetConverter::NewLC();
charConv->PrepareToConvertToOrFromL( aEncoding, aFileSession );
TInt state = CCnvCharacterSetConverter::KStateDefault;
TInt rep = 0; // number of unconvertible characters
TInt rIndx = 0; // index of first unconvertible character
User::LeaveIfError(
charConv->ConvertToUnicode( outPtr, aInBuf, state, rep, rIndx ) );
CleanupStack::PopAndDestroy( charConv );
CleanupStack::Pop(); // outBuf
*aOutBuf = outBuf;
}
示例12: GetMessageL
void CLocaLogicImpl::GetMessageL(const CBBBtDeviceList* devices,
const TTime& aAtTime,
TInt& doSendToIndex,
TInt& aMessageCode, TDes& aWithName,
TDes& aWithTitle, auto_ptr<HBufC8>& aBody)
{
CALLSTACKITEM_N(_CL("CLocaLogicImpl"), _CL("GetMessage"));
TInterpreterAutoLock interpr;
doSendToIndex=-1;
TInt count=-1;
const TBBBtDeviceInfo* dev=0;
TInt max_seen_priority=-1;
for (dev=devices->First(); dev; dev=devices->Next()) count++;
python_ptr<PyObject> dict_general(PyDict_New());
if (! dict_general ) User::Leave(KErrNoMemory);
AddToPyDict(dict_general, "nodename", iNodeName);
AddToPyDict(dict_general, "time", aAtTime);
AddToPyDict(dict_general, "bt_count", count);
// borrowed
PyObject* main_module = PyImport_AddModule("__main__");
if (! main_module ) User::Leave(KErrNoMemory);
// borrowed
PyObject* global_dict = PyModule_GetDict(main_module);
if (! global_dict ) User::Leave(KErrNoMemory);
// borrowed
TInt index=0;
dev=devices->First(); // first is the node itself
for (dev=devices->Next(); dev; dev=devices->Next()) {
index++;
TBuf<15> mac;
dev->iMAC.IntoStringL(mac);
AddToPyDict(dict_general, "mac", mac);
AddToPyDict(dict_general, "majorclass", dev->iMajorClass());
AddToPyDict(dict_general, "minorclass", dev->iMinorClass());
TBool found=EFalse;
python_ptr<PyObject> dict_devstats(PyDict_New());
{
TBuf<50> node;
TDevStats s;
for(found=iDevStats->FirstStats(*dev, node, s); found;
found=iDevStats->NextStats(*dev, node, s)) {
python_ptr<PyObject> dict_dev(
DevStatToPyDict(s));
auto_ptr<HBufC8> node8(HBufC8::NewL(node.Length()+2));
TPtr8 p=node8->Des();
iCC->ConvertFromUnicode(p, node);
node8->Des().ZeroTerminate();
AddToPyDict(dict_devstats, (char*)node8->Ptr(), dict_dev);
}
}
python_ptr<PyObject> dict_msgstats(0);
{
TMessageStats s;
iMessageStats->GetStatsL(*dev, s);
dict_msgstats.reset(MessageStatToPyDict(s));
}
for (int i=0; i<iFunctions->Count(); i++) {
TScriptError err=RunScript(main_module,
global_dict, iFunctions->MdcaPoint(i), max_seen_priority,
dict_general.get(), dict_devstats.get(),
dict_msgstats.get(),
aMessageCode, aWithName,
aWithTitle, aBody, iErrorMsgBuf, dev->iMAC()
);
if (err>EHighestPriority) {
#if !defined(__WINS__) && !defined(CONTEXTLOCA)
if (IsInArray(iErrorFunctions, iFunctions->MdcaPoint(i))) {
PyErr_Clear();
continue;
}
#endif
AddToArrayL(iErrorFunctions, iFunctions->MdcaPoint(i));
TBuf<50> name;
TInt state=CCnvCharacterSetConverter::KStateDefault;
iCC->ConvertToUnicode(name, iFunctions->MdcaPoint(i), state);
name.SetLength(name.Length()-1);
if (err==EPythonError) {
AppendCheckingSpaceL(iErrorMsgBuf, _L(" in script "));
AppendCheckingSpaceL(iErrorMsgBuf, name);
ReportPythonError(iErrorMsgBuf);
} else {
Reporting().UserErrorLog( iErrorMsgBuf,
_L(" in script "), name);
}
} else if (err==EHighestPriority) {
doSendToIndex=index;
}
}
}
/*
// phone or PDA
//.........这里部分代码省略.........