setlocale() crashes when given ".iso-8859-1" 
Author Message
 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.


Tue, 06 May 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. iconv and ISO-8859-1 £ sign gives EILSEQ

2. URGENT::encoding a ANSI string to "ISO-8859-1"

3. URGENT::encoding a ANSI string to "ISO-8859-1"

4. URGENT::encoding a ANSI string to "ISO-8859-1"

5. How to decode a iso-8859-1 string

6. UCS-2 to Latin1 (ISO-8859-1) conversions

7. convert ISO-8859/1 to PC-8

8. iso-8859-2

9. setlocale() and the "C" locale

10. setlocale(LC_TIME, "whatever") not affecting ctime()

11. ISO OF "C" SOURCE CODE FORMATTER

12. CFileDialog gives "Application Error"

 

 
Powered by phpBB® Forum Software