本文整理汇总了C++中std::u16string::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ u16string::begin方法的具体用法?C++ u16string::begin怎么用?C++ u16string::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::u16string
的用法示例。
在下文中一共展示了u16string::begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// from utf16 tans to utf8(or gbk)
inline static std::string to_utf8(const std::u16string& in) {
std::string out;
#ifdef MMSEG_GBK
gbkTrans(in.begin(), in.end(), out);
#else
unicodeToUtf8(in.begin(), in.end(), out);
#endif
return out;
}
示例2: renderString
void TextLabels::renderString( const std::u16string &str, vec2 *cursor, float stretch )
{
std::u16string::const_iterator itr;
for( itr = str.begin(); itr != str.end(); ++itr ) {
// retrieve character code
uint16_t id = (uint16_t)*itr;
if( mFont->contains( id ) ) {
// get metrics for this character to speed up measurements
Font::Metrics m = mFont->getMetrics( id );
// skip whitespace characters
if( !isWhitespaceUtf16( id ) ) {
size_t index = mVertices.size();
Rectf bounds = mFont->getBounds( m, mFontSize );
mVertices.push_back( vec3( *cursor + bounds.getUpperLeft(), 0 ) );
mVertices.push_back( vec3( *cursor + bounds.getUpperRight(), 0 ) );
mVertices.push_back( vec3( *cursor + bounds.getLowerRight(), 0 ) );
mVertices.push_back( vec3( *cursor + bounds.getLowerLeft(), 0 ) );
bounds = mFont->getTexCoords( m );
mTexcoords.push_back( bounds.getUpperLeft() );
mTexcoords.push_back( bounds.getUpperRight() );
mTexcoords.push_back( bounds.getLowerRight() );
mTexcoords.push_back( bounds.getLowerLeft() );
mIndices.push_back( index + 0 ); mIndices.push_back( index + 3 ); mIndices.push_back( index + 1 );
mIndices.push_back( index + 1 ); mIndices.push_back( index + 3 ); mIndices.push_back( index + 2 );
mOffsets.insert( mOffsets.end(), 4, mOffset );
}
if( id == 32 )
cursor->x += stretch * mFont->getAdvance( m, mFontSize );
else
cursor->x += mFont->getAdvance( m, mFontSize );
}
}
//
mBoundsInvalid = true;
}
示例3: patternMatch
bool RegexStore::patternMatch(std::u16string& in_string) {
//No pattern matches when we don't have a valid pattern
if (not is_compiled) {
return false;
}
//Check for a match
regmatch_t pmatch;
std::string tmp_str(in_string.begin(), in_string.end());
int match = regexec(&exp, tmp_str.c_str(), 1, &pmatch, 0);
//Make sure that each character was matched and that the entire input string
//was consumed by the pattern
if (0 == match and 0 == pmatch.rm_so and in_string.size() == pmatch.rm_eo) {
return true;
}
else {
return false;
}
}
示例4: preparePattern
/*
* Create a new regex pattern if necessary, or keep the old one if the
* pattern has not changed
* Returns true on success, false on failure.
*/
bool RegexStore::preparePattern(std::u16string& patt) {
//New pattern? Clear out the existing regex_t
if (is_compiled and this->pattern != patt) {
//std::cerr<<"Replacing pattern "<<std::string(pattern.begin(), pattern.end())<<" with "<<std::string(patt.begin(), patt.end())
regfree(&exp);
is_compiled = false;
}
//Do we need to compile a new regex pattern?
if (not is_compiled) {
//Compile a new regex pattern using the ascii string representation
std::string tmp_string(patt.begin(), patt.end());
int err = regcomp(&exp, tmp_string.c_str(), REG_EXTENDED);
//Return without creating an expression if this failed
if (0 != err) {
return false;
//is_compiled remains false
}
else {
pattern = patt;
is_compiled = true;
}
}
return true;
}
示例5:
path::path( std::u16string const & pathname ) : pathname_( pathname.begin(), pathname.end() )
{
}
示例6: string
std::string UTF16ToASCII(const std::u16string& utf16) {
#if 0
DCHECK(isStringASCII(utf16)) << UTF16ToUTF8(utf16);
#endif
return std::string(utf16.begin(), utf16.end());
}
示例7:
std::vector<char16_t> getChar16VectorFromUTF16String(const std::u16string& utf16)
{
return std::vector<char16_t>(utf16.begin(), utf16.end());
}