Пример #1
0
void InitOperCharsets()
{
	csList.clear();
	charset_struct *list[128];
	int count = charset_table.GetList(list, 128);
	cstrhash<charset_struct*> hash;
	int i;
	for (i = 0; i<count; i++) hash[list[i]->name] = list[i];

	ccollect< carray<char> > stringList;
	if (LoadStringList(charsetSection, stringList))
	{
		for (i = 0; i<stringList.count(); i++) 
		{
			charset_struct ** p = hash.exist(stringList[i].ptr());
			if (p)	csList.append(*p);
		}
	}



	if (csList.count()<=0)
	{
		const char *lang = sys_locale_lang();
		if (!strcmp("ru", lang))
		{
#ifdef WIN32		
			csList.append(charset_table[CS_WIN1251]);
			csList.append(charset_table[CS_CP866]);
			csList.append(charset_table[CS_UTF8]);
#else
			csList.append(charset_table[CS_UTF8]);
			csList.append(charset_table[CS_WIN1251]);
			csList.append(charset_table[CS_KOI8R]);
			csList.append(charset_table[CS_CP866]);
#endif
		}
	}

	if (csList.count()<=0)
	{
		csList.append(charset_table[CS_UTF8]);
		csList.append(&charsetLatin1);
	}
}
Пример #2
0
static  bool InitLocale( const sys_char_t* dir, const char* id )
{
	if ( id[0] == '-' ) { return true; }

	std::vector<sys_char_t> fn =
#ifdef _WIN32
	   carray_cat<sys_char_t>( dir, utf8_to_sys( "\\ltext." ).data() );
#else
	   carray_cat<sys_char_t>( dir, utf8_to_sys( "/ltext." ).data() );
#endif

	if ( id[0] != '+' )
	{
		return LTextLoad( LTPath( fn.data(), id ).data() );
	}

	return LTextLoad( LTPath( fn.data(), sys_locale_lang_ter() ).data() ) ||
	       LTextLoad( LTPath( fn.data(), sys_locale_lang() ).data() );
};