|
From: <set...@us...> - 2006-04-19 18:47:22
|
Revision: 1313 Author: sethdill Date: 2006-04-19 11:47:17 -0700 (Wed, 19 Apr 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1313&view=rev Log Message: ----------- Much improved initialization of the charsets table for the macintosh. It now queries the OS for a list of the available character sets. Windows still uses pre-defined list, and will until I figure out how to ask COM for this information. Modified Paths: -------------- Frontier/trunk/Common/source/langstartup.c Modified: Frontier/trunk/Common/source/langstartup.c =================================================================== --- Frontier/trunk/Common/source/langstartup.c 2006-04-19 08:34:26 UTC (rev 1312) +++ Frontier/trunk/Common/source/langstartup.c 2006-04-19 18:47:17 UTC (rev 1313) @@ -590,23 +590,6 @@ static boolean langinit_charset_consttable (void) { - /* - First pass at a way to populate a table with many of - the known charsets. Key is the MIME charset name (the - IANA-registered name), value is the platform-dependent - value that identifies that character set. (Constants on - Mac, code page id numbers on Windows.) - - There may be a one-hit memory leak here, because nothing is done - to release the table... but maybe it can't be released, because - it needs to stick around? - - A better approach on both platforms would be some routine that - asks the OS for a list of the character sets it supports. - I couldn't find anything like that on the Mac, and on Windows - it requires COM which I couldn't get to work! - */ - hdlhashtable hcharsetconsttable; if (!tablenewsystemtable (langtable, (ptrstring) "\x08" "charsets", &hcharsetconsttable)) @@ -615,6 +598,43 @@ pushhashtable (hcharsetconsttable); #if MACVERSION + #if 1 + OSStatus err; + ItemCount ct, actual_ct, i; + + err = TECCountAvailableTextEncodings( &ct ); + if ( err != noErr ) { + pophashtable(); + + return (true); // don't kill the whole startup + } + + TextEncoding enc; + TextEncoding availEncodings[ ct ]; + bigstring ianaName; + + err = TECGetAvailableTextEncodings ( availEncodings, ct, &actual_ct ); + if ( err != noErr ) { + pophashtable(); + + return (true); // we don't want to kill the whole startup here + } + + for ( i = 0; i < actual_ct; i++ ) { + enc = availEncodings[ i ]; + // enc = i; + + err = TECGetTextEncodingInternetName( enc, ianaName ); + if ( err != noErr ) + continue; + + nullterminate( ianaName ); + + if ( ! hashsymbolexists( ianaName ) ) + langassignlongvalue( hcharsetconsttable, ianaName, enc ); + } + #endif + #if 0 addlong( "ASCII", kCFStringEncodingASCII ); addlong( "MacRoman", kCFStringEncodingMacRoman ); addlong( "MACINTOSH", kCFStringEncodingMacRoman ); @@ -658,6 +678,7 @@ addlong( "UTF-16le", kCFStringEncodingUTF16LE ); addlong( "UTF-16be", kCFStringEncodingUTF16BE ); #endif + #endif #endif #if WIN95VERSION This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |