This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Locale problem on Solaris 10


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;
}

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]