本文整理汇总了C++中UTF8::length方法的典型用法代码示例。如果您正苦于以下问题:C++ UTF8::length方法的具体用法?C++ UTF8::length怎么用?C++ UTF8::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::length方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
int FPID::Parse( const UTF8& aId )
{
clear();
size_t cnt = aId.length() + 1;
char tmp[cnt]; // C string for speed
std::strcpy( tmp, aId.c_str() );
const char* rev = EndsWithRev( tmp, tmp+aId.length(), '/' );
size_t revNdx;
size_t partNdx;
int offset;
//=====<revision>=========================================
if( rev )
{
revNdx = rev - aId.c_str();
// no need to check revision, EndsWithRev did that.
revision = aId.substr( revNdx );
--revNdx; // back up to omit the '/' which precedes the rev
}
else
{
revNdx = aId.size();
}
//=====<nickname>==========================================
if( ( partNdx = aId.find( ':' ) ) != aId.npos )
{
offset = SetLibNickname( aId.substr( 0, partNdx ) );
if( offset > -1 )
{
return offset;
}
++partNdx; // skip ':'
}
else
{
partNdx = 0;
}
//=====<footprint name>====================================
if( partNdx >= revNdx )
return partNdx;
SetFootprintName( aId.substr( partNdx, revNdx ) );
return -1;
}
示例2: Parse
int FPID::Parse( const UTF8& aId )
{
clear();
const char* buffer = aId.c_str();
const char* rev = EndsWithRev( buffer, buffer+aId.length(), '/' );
size_t revNdx;
size_t partNdx;
int offset;
//=====<revision>=========================================
// in a FPID like discret:R3/rev4
if( rev )
{
revNdx = rev - buffer;
// no need to check revision, EndsWithRev did that.
revision = aId.substr( revNdx );
--revNdx; // back up to omit the '/' which precedes the rev
}
else
{
revNdx = aId.size();
}
//=====<nickname>==========================================
if( ( partNdx = aId.find( ':' ) ) != aId.npos )
{
offset = SetLibNickname( aId.substr( 0, partNdx ) );
if( offset > -1 )
{
return offset;
}
++partNdx; // skip ':'
}
else
{
partNdx = 0;
}
//=====<footprint name>====================================
if( partNdx >= revNdx )
return partNdx; // Error: no footprint name.
// Be sure the footprint name is valid.
// Some chars can be found in board file (in old board files
// or converted files from an other EDA tool
std::string fpname = aId.substr( partNdx, revNdx-partNdx );
ReplaceIllegalFileNameChars( &fpname, '_' );
SetFootprintName( UTF8( fpname ) );
return -1;
}
示例3: generateJSONString
static void generateJSONString(Error& error, const HOutputStream& out, const UTF8& s)
{
UTF16Buffer sb(2 + s.length() + 1);
sb << '"';
if (error)
return;
for (const Chr8* p = s.ptr(); (*p) != '\0'; p++)
{
Chr8 c = *p;
switch (c)
{
case '\"' : sb << '\\' << '\"'; break;
case '\\' : sb << '\\' << '\\'; break;
case '/' : sb << '\\' << '/'; break;
case '\b' : sb << '\\' << 'b'; break;
case '\f' : sb << '\\' << 'f'; break;
case '\n' : sb << '\\' << 'n'; break;
case '\r' : sb << '\\' << 'r'; break;
case '\t' : sb << '\\' << 't'; break;
default:
if (c >= 0x20)
{
sb << c;
}
else
{
sb << UTF8("\\u00") << UTF8::format("%.2X",UInt32(c));
}
break;
}
}
sb << '"';
out->twrite(error, UTF8(sb));
};