
setlocale() crashes when given ".iso-8859-1"
Just FYI, VC++6SP4 setlocale() crashes (in a hard to debug way -- stack
trace isn't available) if it's given an encoding (aka code page) name
that is more than eight characters.
I noticed it when trying to do:
setlocale(LC_ALL, "English_United States.iso-8859-1");
Since Microsoft's setlocale() doesn't understand MIME names (as
specified at http://www.*-*-*.com/
sets), this wouldn't do what I want anyway, but it would be nice if
setlocale() just returned NULL instead of crashing on unrecognized
input.
Jamshid Afshar
#include <iostream.h>
#include <locale.h>
const char* ornull(const char* s) {
return s ? s : "(NULL)";
Quote:
}
int main() {
cout << ornull(setlocale(LC_ALL, "English_United States")) <<
endl; // okay
cout << ornull(setlocale(LC_ALL, "English_United States.1252")) <<
endl; // okay
cout << ornull(setlocale(LC_ALL, "English_US.blahblah")) << endl; //
NULL
cout << ornull(setlocale(LC_ALL, "English_US.blahblahx")) <<
endl; // crash
return 0;
Quote:
}
Sent via Deja.com http://www.*-*-*.com/
Before you buy.