当前位置: 首页>>代码示例>>C++>>正文


C++ UTF8::length方法代码示例

本文整理汇总了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;
}
开发者ID:general231,项目名称:kicad-source-mirror,代码行数:53,代码来源:fpid.cpp

示例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;
}
开发者ID:CastMi,项目名称:kicad-source-mirror,代码行数:55,代码来源:fpid.cpp

示例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));
};
开发者ID:tomazos,项目名称:Folderscope,代码行数:40,代码来源:JSON.cpp


注:本文中的UTF8::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。