I am trying to print a wstring/wchar_t in xcode to the console but unfortunatelly it only works with basic chars (i think ascii) chars, everything else gets displayed in numbers, for instance the following:
std::cout << "äöüu"<< std::endl;
std::wcout << L"äöüu" << std::endl;
while the cout version prints "äöüu" as expected I get the following when using wchar_t:
\344\366\374u
any ideas about how to fix this? I am using xcode 3.2.2 64 bit and gcc 4.2 with file encoding set to Unicode (UTF-8)
Thanks!
i had a sinilar problem but with wostream/wofstream. Googled it and this was the anser:
tc_ofstream ofs;
if (sizeof(TCHAR) == sizeof(wchar_t))
{
//codecvt_utf16<TCHAR> utf16; cannot make use of non-dynamic value
locale loc ( locale::classic() ,new codecvt_utf16<TCHAR> );
ofs.imbue( loc );
ofs.open( _T(".\\test.txt") ,tc_ios::binary );
TCHAR BOM = 0xFEFF; ofs << BOM;
ofs << _T("UNICODE") << endl;
}
else
{
ofs.open( _T(".\\test.txt") ,tc_ios::binary );
ofs << _T("NON-UNICODE") << endl;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With