|
From: <set...@us...> - 2006-05-04 17:39:15
|
Revision: 1347 Author: sethdill Date: 2006-05-04 10:39:10 -0700 (Thu, 04 May 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1347&view=rev Log Message: ----------- Fixed error handling in isTextEncodingAvailable, with Andre's help. Also, renamed getTextEncodingID to the more precise getTextEncodingIDFromIANA (which leaves room for other methods to determine a text encoding id). Modified Paths: -------------- Frontier/trunk/Common/source/strings.c Modified: Frontier/trunk/Common/source/strings.c =================================================================== --- Frontier/trunk/Common/source/strings.c 2006-05-04 04:43:06 UTC (rev 1346) +++ Frontier/trunk/Common/source/strings.c 2006-05-04 17:39:10 UTC (rev 1347) @@ -81,7 +81,7 @@ /* declarations */ static boolean converttextencoding( Handle, Handle, const long, const long, long * ); -static boolean getTextEncodingID( bigstring, long * ); +static boolean getTextEncodingIDFromIANA( bigstring, long * ); #ifdef WIN95VERSION static boolean UnicodeToAnsi(Handle, Handle, unsigned long, long *); @@ -2466,7 +2466,7 @@ /* convert an "internet name" for an encoding into a platform-specific id for the character set */ -static boolean getTextEncodingID( bigstring bsEncodingName, long * encodingId ) +static boolean getTextEncodingIDFromIANA( bigstring bsEncodingName, long * encodingId ) { #ifdef MACVERSION @@ -2548,30 +2548,14 @@ { long encodingId; - if ( ! getTextEncodingID( bsEncodingName, &encodingId ) ) - { - /* - if the encoding isn't recognized then getTextEncodingId set an error - we need to clear that error - */ - langerrorclear(); - + disablelangerror(); + + if ( ! getTextEncodingIDFromIANA( bsEncodingName, &encodingId ) ) return (false); - } - #ifdef MACVERSION + enablelangerror(); - // 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 seems to have no code page - return (true); - - #endif + return ( true ); } static boolean converttextencoding( Handle h, Handle hresult, const long inputcharset, const long outputcharset, long * OSStatusCode ) @@ -2732,10 +2716,10 @@ #endif - if ( ! getTextEncodingID( charsetIn, (long *) &teInputSet ) ) + if ( ! getTextEncodingIDFromIANA( charsetIn, (long *) &teInputSet ) ) return (false); - if ( ! getTextEncodingID( charsetOut, (long *) &teOutputSet ) ) + if ( ! getTextEncodingIDFromIANA( charsetOut, (long *) &teOutputSet ) ) return (false); if ( ! converttextencoding( hString, hresult, (long) teInputSet, (long) teOutputSet, &err ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |