在我的應用程序中,我必須使用CORBA :: WChar *(或等效的wchar_t *),但我的程序還需要將一些信息保存到PostgreSQL數據庫。在C++中使用PostgreSQL插入數據我使用了SOCI。還有的問題,因爲:如何將wchar_t(或wchar_t *或CORBA :: WChar *)轉換爲字符串?
The following types are currently supported for use with into and use expressions:
char (for character values)
short, int, unsigned long, long long, double (for numeric values)
char*, char[], std::string (for string values)
std::tm (for datetime values)
soci::statement (for nested statements and PL/SQL cursors)
soci::blob (for Binary Large OBjects)
soci::row_id (for row identifiers)
所以世界上沒有wchar_t的*或WSTRING支持......我需要CORBA :: WCHAR(或wchar_t的wchar_t的或*)到字符串轉換。這個怎麼做?
我也有寬字符(和字符串)問題,用代碼塊10.5:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
const wchar_t *val = L"ąśżźćłóń";
wcout << val << "\n";
return 0;
}
顯示:
E:\Temp\Untitled1.cpp||In function 'int main(int, char**)':|
E:\Temp\Untitled1.cpp|7|error: converting to execution character set: Invalid argument|
||=== Build finished: 1 errors, 0 warnings ===|
如何解決呢?
我還需要代碼是可移植的,我可以在unix/linux和windows上運行它。
你試過了嗎:wcout << val << L「\ n」; ? – marcinj
@luskan:我試過沒有結果... –