|
From: <set...@us...> - 2006-04-24 22:28:44
|
Revision: 1332 Author: sethdill Date: 2006-04-24 15:28:36 -0700 (Mon, 24 Apr 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1332&view=rev Log Message: ----------- The mac's system.charsets table is now equivalent to the windows version. That is, the names are the IANA codes for the character sets, and the values are the 'display names'. Also, pulled out a bunch of old, commented-out code from some of the ___toANSI and ANSIto___ functions. Modified Paths: -------------- Frontier/trunk/Common/source/langstartup.c Frontier/trunk/Common/source/strings.c Modified: Frontier/trunk/Common/source/langstartup.c =================================================================== --- Frontier/trunk/Common/source/langstartup.c 2006-04-24 22:07:22 UTC (rev 1331) +++ Frontier/trunk/Common/source/langstartup.c 2006-04-24 22:28:36 UTC (rev 1332) @@ -426,21 +426,20 @@ static boolean initCharsetsTable (hdlhashtable cSetsTable) { -#if 1 #if MACVERSION 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 enc, encOut; TextEncoding availEncodings[ ct ]; - bigstring ianaName; + bigstring ianaName, displayName; + unsigned long lenDisplayName; + RegionCode reg; err = TECGetAvailableTextEncodings ( availEncodings, ct, &actual_ct ); if ( err != noErr ) @@ -465,8 +464,20 @@ if ( err != noErr ) continue; - langassignlongvalue( cSetsTable, ianaName, (long) enc ); + /* + get the encoding's display name, which is the value of the table cell + */ + err = GetTextEncodingName( enc, kTextEncodingFullName, verUS, kTextEncodingMacRoman, 255, &lenDisplayName, ®, &encOut, (TextPtr) displayName + 1 ); + if ( err != noErr ) + continue; + + displayName[ 0 ] = (unsigned char) lenDisplayName; + + langassignstringvalue( cSetsTable, ianaName, displayName ); } + + return (true); + #endif #if WIN95VERSION @@ -520,10 +531,10 @@ pMultiLanguage->lpVtbl->Release( pMultiLanguage ); // CoTaskMemFree( (LPVOID) pcpInfo ); -#endif -#endif done: return (true); + +#endif } /* initCharsetsTable */ Modified: Frontier/trunk/Common/source/strings.c =================================================================== --- Frontier/trunk/Common/source/strings.c 2006-04-24 22:07:22 UTC (rev 1331) +++ Frontier/trunk/Common/source/strings.c 2006-04-24 22:28:36 UTC (rev 1332) @@ -27,8 +27,11 @@ #include "frontier.h" #include "standard.h" -#include "FrontierWinMain.h" +#ifdef WIN95VERSION + #include "FrontierWinMain.h" +#endif + #include "font.h" #include "memory.h" #include "quickdraw.h" @@ -2336,10 +2339,6 @@ /* 7.0b42 PBS: convert from ANSI to Unicode. Borrowed from Microsoft sample code. - - 2006-04-24 smd: - fixed the description in the previous comment line - rewrote most of the function */ ULONG cbUni, cCharacters; @@ -2444,7 +2443,19 @@ if ( ! getTextEncodingID( bsEncodingName, &encodingId ) ) return (false); - return ( encodingId >= 0 ); + #ifdef MACVERSION + + // the mac version has no encoding id 0, so this means a failure + return ( encodingId >= 0 ); + + #endif + + #ifdef WIN95VERSION + + // we use 0 to refer to UTF-16 on Windows, as it's the default character set and has no code page + return (true); + + #endif } static boolean converttextencoding( Handle h, Handle hresult, const long inputcharset, const long outputcharset) { @@ -2616,7 +2627,7 @@ boolean utf16toansi (Handle h, Handle hresult) { /* - 7.0b42 PBS: convert from UTF-16 to UTF-8 character sets. + 7.0b42 PBS: convert from UTF-16 to iso-8859-1 character sets. */ #ifdef WIN95VERSION @@ -2638,60 +2649,10 @@ #endif #ifdef MACVERSION -/* - if (((*h) [0] == '\xFF') || ((*h) [0] == '\xEF')) /#pop byte order mark#/ - - pullfromhandle (h, 0, 2, NULL); - - // why do we need a string starting with a 0??? - if ((*h) [0] != '\0') - - insertinhandle (h, 0, NULL, 1); -*/ + if (!converttextencoding (h, hresult, kTextEncodingUnicodeDefault, kTextEncodingWindowsLatin1)) return (false); -/* OSErr err = noErr; - - UnicodeToTextInfo utinfo; - - UnicodeMapping utmapping; - - ByteCount ctunibytes, ctansibytes; - - long lentext = gethandlesize (h); - - sethandlesize (h, lentext + 1); - - (*h) [lentext] = '\0'; - - utmapping.unicodeEncoding = kTextEncodingUnicodeDefault; - - utmapping.otherEncoding = kTextEncodingISOLatin1; - - utmapping.mappingVersion = kUnicodeUseLatestMapping; - - err = CreateUnicodeToTextInfo (&utmapping, &utinfo); - - sethandlesize (hresult, lentext * 2); - - pullfromhandle (h, 0, 2, NULL); - - insertinhandle (h, 0, NULL, 1); - - lentext = gethandlesize (h); - - err = ConvertFromUnicodeToText (utinfo, lentext, (ConstUniCharArrayPtr) *h, - kUnicodeUseFallbacksMask, - 0, NULL, NULL, NULL, - lentext * 2, &ctunibytes, &ctansibytes, *hresult); - - DisposeUnicodeToTextInfo (&utinfo); - - sethandlesize (hresult, ctansibytes); - - sethandlesize (hresult, gethandlesize (hresult) - 1); #*pop trailing terminator*/ - #endif return (true); @@ -2733,38 +2694,6 @@ if (!converttextencoding (h, hresult, kCFStringEncodingUTF8, kTextEncodingWindowsLatin1)) return (false); -/* OSErr err = noErr; - - long lentext = gethandlesize (h); - - TECObjectRef converter; - - ByteCount ctunibytes, ctansibytes, ctflushedbytes; - - sethandlesize (h, lentext + 1); - - (*h) [lentext] = '\0'; - - err = TECCreateConverter (&converter, 0x08000100, kTextEncodingWindowsLatin1); #*0x08000100 is UTF-8*/ - -/* sethandlesize (hresult, lentext * 2); - - if (((*h) [0] == '\xFF') || ((*h) [0] == '\xEF')) #*pop byte order mark*/ - -/* pullfromhandle (h, 0, 3, NULL); - - lentext = gethandlesize (h); - - err = TECConvertText (converter, *h, lentext, &ctunibytes, *hresult, lentext * 2, &ctansibytes); - - TECFlushText (converter, *hresult, lentext * 2, &ctflushedbytes); - - TECDisposeConverter (converter); - - sethandlesize (hresult, ctansibytes); - - sethandlesize (hresult, gethandlesize (hresult) - 1); #*pop trailing terminator*/ - #endif return (true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |