コード例 #1
0
ファイル: main.cpp プロジェクト: ermachkov/bmgui
//конвертирование из CP-1251 в UTF-8
CL_String decode(const CL_String &str)
{
	//строка символов в текущей локали преобразовать в UCS-2 через MultiByteToWideChar,
	//а потом из UCS-2 в кланлибовский UTF-8 через CL_StringHelp::ucs2_to_text.
	CL_String16 result;
	int count = MultiByteToWideChar(1251, 0, str.c_str(), str.size(), NULL, 0);
	result.resize(count);
	MultiByteToWideChar(1251, 0, str.c_str(), str.size(), result.data(), count);
	
	return CL_StringHelp::ucs2_to_text(result);
}
コード例 #2
0
void CL_Collada_Triangles_Impl::load_primitive(CL_DomElement &primitive_element)
{
	unsigned int count = stride * triangle_count * 3;

	primitive.resize(count);

	CL_String points = primitive_element.get_text();
	const CL_String::char_type *primitive_text = points.c_str();

	for (unsigned int cnt=0; cnt < count; cnt++)
	{
		if (!(*primitive_text))
			throw CL_Exception("Primitive data count mismatch");

		int value = atoi(primitive_text);
		primitive[cnt] = value;

		while(*primitive_text)
		{
			if (*(primitive_text++) <= ' ')	// Find whitespace
				break;
		}

		while(*primitive_text)
		{
			if ((*primitive_text) > ' ')	// Find end of whitespace
				break;
			primitive_text++;
		}

	}
	if (*primitive_text)
			throw CL_Exception("Primitive data count mismatch (end)");
}
コード例 #3
0
void CL_Collada_Triangles_Impl::validate_vcount(CL_DomElement &vcount_element)
{
	CL_String points = vcount_element.get_text();
	const CL_String::char_type *vcount_text = points.c_str();

	for (unsigned int cnt=0; cnt < triangle_count; cnt++)
	{
		if (!(*vcount_text))
			throw CL_Exception("VCount data count mismatch");

		int value = atoi(vcount_text);

		if (value != 3)
			throw CL_Exception("Only triangles are supported. Export your mesh as triangles please");

		while(*vcount_text)
		{
			if (*(vcount_text++) <= ' ')	// Find whitespace
				break;
		}

		while(*vcount_text)
		{
			if ((*vcount_text) > ' ')	// Find end of whitespace
				break;
			vcount_text++;
		}

	}
	if (*vcount_text)
			throw CL_Exception("VCount data count mismatch (end)");
}
コード例 #4
0
ファイル: directory.cpp プロジェクト: PaulFSherwood/cplusplus
bool CL_Directory::set_current(const CL_String &dir_name)
{
#ifdef WIN32
	return SetCurrentDirectory(CL_StringHelp::utf8_to_ucs2(dir_name).c_str()) == TRUE;
#else
	return chdir(dir_name.c_str()) == 0;
#endif
}