Locale problem on Solaris 10
Sam Varshavchik
mrsam@courier-mta.com
Sat Feb 23 21:31:00 GMT 2013
I'm playing with OpenCSW's gcc package on Solaris 10. I'm getting odd
results from the following test program.
With the environment locale set to UTF-8, I get the expected exception:
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_filebuf::underflow incomplete character in file
But it I set LANG to en_US.ISO8859-1 (I have the legacy locale package
installed), the wide character that I end up getting is:
[805306467]
Which I can't make heads or tails of. Other code I'm looking at suggests
that wide characters are unicode characters on this platform. Repeating this
experiment on Freebsd gets the expected result:
[227]
#include <locale>
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <stdlib.h>
int main()
{
setlocale(LC_ALL, "");
std::ofstream f("/tmp/8859");
f << "\xe3" << std::flush;
f.close();
std::wifstream i("/tmp/8859");
typedef std::istreambuf_iterator<wchar_t> iter_t;
std::wstring w=std::wstring(iter_t(i), iter_t());
for (wchar_t wc:w)
{
if ((wc & 0x7f) == wc)
std::cout << (char)wc;
else
std::cout << "[" << (int)wc << "]";
}
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20130223/33c36ba1/attachment.sig>
More information about the Libstdc++
mailing list