'C++ sprintf and cyrillic symbols, VS2019, Linux
I'm working with sqlite3 from VS2019 with remote gcc on Linux. I need to create a query to a database, I'm using sprintf.
BOOL MwProtonProtocol::GetObjectindexByTypename(const char* ObjectTypeName, int &iObjectIndex)
{
sqlite3_stmt* stmt;
char* sQuery;
//!!!!!!!!here!!!!! But I've got the problem!!
sprintf( sQuery, "SELECT objectindex FROM ObjectTable WHERE objecttypeindex IN(SELECT objecttypeindex FROM ObjectTypeTable WHERE objecttypename = '%s')", ObjectTypeName);
int res = sqlite3_prepare_v2(m_pDatabase, sQuery, -1, &stmt, 0);
if (res == SQLITE_OK)
{
GlobLogPrintf("ZemonDBArch.sqlite ObjectTable is READ");
while ((sqlite3_step(stmt) == SQLITE_ROW) || (sqlite3_step(stmt) == SQLITE_OK))
iObjectIndex = sqlite3_column_int(stmt, 2);
return TRUE;
}
return FALSE;
}
...
int iObjectIndex(0);
const char* ObjectTypeName("Фотон-1");
if (GetObjectindexByTypename(ObjectTypeName, iObjectIndex))
{
//do something
}
If ObjectTypeName contains English text, I get the right string in sQuery. But if it's Russian, then I got this in the variable:
and in sQuery Cyrillic symbols looks like this:
How to get the right Cyrillic string??
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


