本文整理汇总了C++中UT_String::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_String::begin方法的具体用法?C++ UT_String::begin怎么用?C++ UT_String::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_String
的用法示例。
在下文中一共展示了UT_String::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UT_W2S
//======================== METHOD DECLARATION =======================
// METHOD NAME : UT_W2S
//---------------------------------------------------------------------
/// \param src
/// \param dst
/// \return
//---------------------------------------------------------------------
// DESCRIPTION :
/// Convert a 'wstring' to a string.
//=====================================================================
void UT_W2S( const UT_String &src, string &dst )
{
#if defined(TARGET_IOS) || defined(TARGET_MACOS)
CFStringRef strref = CFStringCreateWithCharactersNoCopy( 0, src.data(), src.length(), kCFAllocatorNull );
CFIndex usedBufLen;
CFStringGetBytes( strref, CFRangeMake( 0, src.length() ), CFStringGetSystemEncoding(), '?', false, NULL, 0, &usedBufLen );
char *buffer = (char*)MEM_ALLOC(usedBufLen * sizeof(char));
CFStringGetBytes( strref, CFRangeMake( 0, src.length() ), CFStringGetSystemEncoding(), '?', false, (UInt8 *) buffer, usedBufLen, &usedBufLen );
CFRelease( strref );
dst.assign( buffer, usedBufLen );
MEM_DEALLOC(buffer);
if ( ! dst.empty() )
dst.erase(dst.begin(), dst.end());
copy( src.begin(), src.end(), back_inserter( dst ));
#else
#ifndef TARGET_WIN32
dst = string();
if (src.length() < 1)
{
return;
}
unsigned char *dstC = (unsigned char*)MEM_ALLOC(6 * src.length() * sizeof(unsigned char));
unsigned char *initial = dstC;
UTF16 *srcC = const_cast<UTF16*>(src.c_str());
ConvertUTF16toUTF8(&srcC, srcC + src.length(), &dstC, dstC + 6 * src.length());
dst.append((const char *)dstC);
MEM_DEALLOC(initial);
#else // TARGET_WIN32
(void)src;
(void)dst;
#endif
#endif
}
示例2: UT_A2W
//======================== FUNCTION DECLARATION =====================
// FCT NAME : UT_A2W
//---------------------------------------------------------------------
/// \param pSrc
/// \return
//---------------------------------------------------------------------
// DESCRIPTION :
/// Convert ascii to a 'wstring'.
//=====================================================================
void UT_A2W( const char *pSrc, UT_String &dst)
{
#if defined(TARGET_IOS) || defined(TARGET_MACOS)
CFStringRef strref = CFStringCreateWithCStringNoCopy( 0, pSrc, CFStringGetSystemEncoding(), kCFAllocatorNull );
dst = UT_String( strref );
CFRelease( strref );
size_t uLen = strlen( pSrc );
dst.resize( uLen );
UT_String::iterator it = dst.begin();
while( *pSrc )
{
*it = wchar_t( *pSrc );
++it;
++pSrc;
}
#else
dst = UT_String();
if (!pSrc)
return;
while (*pSrc)
{
dst.push_back(UniChar_t(*pSrc));
++pSrc;
}
#endif
}
示例3: UT_W2Int
int UT_W2Int( const UT_String &s )
{
string as;
for ( UT_String::const_iterator it = s.begin(); it != s.end(); ++it )
{
as.insert( as.end(), (char)*it );
}
return atoi( as.c_str() );
}
示例4: UT_W2Float
double UT_W2Float( const UT_String &s )
{
string as;
for ( UT_String::const_iterator it = s.begin(); it != s.end(); ++it )
{
if ( *it == (UniChar_t)',' )
as.insert( as.end(), '.' );
else
as.insert( as.end(), (char)*it );
}
return atof( as.c_str() );
}