eZ Publish  [trunk]
eztextcodec.php
Go to the documentation of this file.
00001 <?php
00002 /**
00003  * File containing the eZTextCodec class.
00004  *
00005  * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
00006  * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
00007  * @version //autogentag//
00008  * @package lib
00009  */
00010 
00011 /*! \defgroup eZI18N Internationalization */
00012 
00013 /*!
00014   \class eZTextCodec eztextcodec.php
00015   \ingroup eZI18N
00016   \brief Handles conversion from one charset to another
00017 
00018   Supports <a href="http://www.ietf.org/rfc/rfc2279.txt">utf8</a> encoding/decoding
00019 
00020 */
00021 
00022 class eZTextCodec
00023 {
00024     function eZTextCodec( $inputCharsetCode, $outputCharsetCode,
00025                           $realInputCharsetCode, $realOutputCharsetCode,
00026                           $inputEncoding, $outputEncoding )
00027     {
00028         $this->RequestedInputCharsetCode = $inputCharsetCode;
00029         $this->RequestedOutputCharsetCode = $outputCharsetCode;
00030         $this->InputCharsetCode = $realInputCharsetCode;
00031         $this->OutputCharsetCode = $realOutputCharsetCode;
00032         $this->InputCharacterEncodingScheme = $inputEncoding;
00033         $this->OutputCharacterEncodingScheme = $outputEncoding;
00034 
00035         $useMBStringExtension = true;
00036         if ( isset( $GLOBALS['eZTextCodecMBStringExtension'] ) )
00037             $useMBStringExtension = $GLOBALS['eZTextCodecMBStringExtension'];
00038 
00039         // NOTE:
00040         // The method eZMBStringMapper::hasMBStringExtension() has been copied and inlined here
00041         // Any modification must be reflected in the method
00042         $hasMBString = ( function_exists( "mb_convert_encoding" ) and
00043                          function_exists( "mb_substitute_character" ) and
00044                          function_exists( "mb_strcut" ) and
00045                          function_exists( "mb_strlen" ) and
00046                          function_exists( "mb_strpos" ) and
00047                          function_exists( "mb_strrpos" ) and
00048                          function_exists( "mb_strwidth" ) and
00049                          function_exists( "mb_substr" ) );
00050 
00051         $useMBString = ( $useMBStringExtension and
00052                          eZTextCodec::useMBString() and
00053                          $hasMBString );
00054 
00055         // Map for conversion functions using encoding functions
00056         $encodingConvertMap = array();
00057         $encodingConvertInitMap = array();
00058         $encodingStrlenMap = array();
00059 
00060         $encodingStrlenMap['unicode'] = 'strlenUnicode';
00061         $encodingStrlenMap['utf-8'] = 'strlenUTF8';
00062         $encodingStrlenMap['singlebyte'] = 'strlenCodepage';
00063         $encodingStrlenMap['doublebyte'] = 'strlenCodepage';
00064 
00065         // Unicode -> other
00066         $encodingConvertMap['unicode']['unicode'] = 'convertNone';
00067         $encodingConvertMap['unicode']['utf-8'] = 'convertUnicodeToUTF8';
00068         $encodingConvertMap['unicode']['singlebyte'] = 'convertUnicodeToCodepage';
00069         $encodingConvertMap['unicode']['doublebyte'] = 'convertUnicodeToCodepage';
00070 
00071         $encodingConvertInitMap['unicode']['singlebyte'] = 'initializeOutputCodepage';
00072         $encodingConvertInitMap['unicode']['doublebyte'] = 'initializeOutputCodepage';
00073 
00074         // UTF8 -> other
00075         $encodingConvertMap['utf-8']['unicode'] = 'convertUTF8ToUnicode';
00076         $encodingConvertMap['utf-8']['utf-8'] = 'convertNone';
00077         $encodingConvertMap['utf-8']['singlebyte'] = 'convertCodepageRev';
00078         $encodingConvertMap['utf-8']['doublebyte'] = 'convertCodepageRev';
00079 
00080         $encodingConvertInitMap['utf-8']['singlebyte'] = 'initializeOutputCodepage';
00081         $encodingConvertInitMap['utf-8']['doublebyte'] = 'initializeOutputCodepage';
00082 
00083         // singlebyte -> other
00084         $encodingConvertMap['singlebyte']['unicode'] = 'convertCodepageToUnicode';
00085         $encodingConvertMap['singlebyte']['utf-8'] = 'convertCodepage';
00086         $encodingConvertMap['singlebyte']['singlebyte'] = 'convertCodepageMapper';
00087         $encodingConvertMap['singlebyte']['doublebyte'] = 'convertCodepageMapper';
00088 
00089         $encodingConvertInitMap['singlebyte']['unicode'] = 'initializeInputCodepage';
00090         $encodingConvertInitMap['singlebyte']['utf-8'] = 'initializeInputCodepage';
00091         $encodingConvertInitMap['singlebyte']['singlebyte'] = 'initializeCodepageMapper';
00092         $encodingConvertInitMap['singlebyte']['doublebyte'] = 'initializeCodepageMapper';
00093 
00094         // doublebyte -> other
00095         $encodingConvertMap['doublebyte']['unicode'] = 'convertCodepageToUnicode';
00096         $encodingConvertMap['doublebyte']['utf-8'] = 'convertCodepage';
00097         $encodingConvertMap['doublebyte']['singlebyte'] = 'convertCodepageMapper';
00098         $encodingConvertMap['doublebyte']['doublebyte'] = 'convertCodepageMapper';
00099 
00100         $encodingConvertInitMap['doublebyte']['unicode'] = 'initializeInputCodepage';
00101         $encodingConvertInitMap['doublebyte']['utf-8'] = 'initializeInputCodepage';
00102         $encodingConvertInitMap['doublebyte']['singlebyte'] = 'initializeCodepageMapper';
00103         $encodingConvertInitMap['doublebyte']['doublebyte'] = 'convertCodepageMapper';
00104 
00105 
00106         $noneConversionFunction = 'convertNone';
00107         $noneStrlenFunction = 'strlenNone';
00108         $conversionFunction = null;
00109         $strlenFunction = null;
00110         $encodingConvertInitFunction = null;
00111 
00112         // NOTE:
00113         // The method eZMBStringMapper::charsetList() hash been copied and inlined here
00114         // Any modification must be reflected in the method
00115         $mbStringCharsets =& $GLOBALS["eZMBCharsetList"];
00116         if ( $useMBString and
00117              !is_array( $mbStringCharsets ) )
00118         {
00119             $charsetList = array( "ucs-4", "ucs-4be", "ucs-4le", "ucs-2", "ucs-2be", "ucs-2le", "utf-32", "utf-32be", "utf-32le", "utf-16",
00120                                   "utf-16be", "utf-16le", "utf-8", "utf-7", "ascii", "euc-jp", "sjis", "eucjp-win", "sjis-win", "iso-2022-jp", "jis",
00121                                   "iso-8859-1", "iso-8859-2", "iso-8859-3", "iso-8859-4", "iso-8859-5", "iso-8859-6", "iso-8859-7", "iso-8859-8",
00122                                   "iso-8859-9", "iso-8859-10", "iso-8859-13", "iso-8859-14", "iso-8859-15", "byte2be", "byte2le", "byte4be",
00123                                   "byte4le", "base64", "7bit", "8bit", "utf7-imap" );
00124             $mbStringCharsets = array();
00125             foreach ( $charsetList as $charset )
00126             {
00127                 $mbStringCharsets[$charset] = $charset;
00128             }
00129         }
00130 
00131         // Is to true if the charsets are the same and they have singlebyte encoding
00132         $isSinglebyteSame = false;
00133         $isSame = false;
00134 
00135         // First detect conversion type
00136         if ( $this->InputCharsetCode == $this->OutputCharsetCode ) // Direct match, no conversion
00137         {
00138             $conversionFunction = $noneConversionFunction;
00139             $encodingConvertInitFunction = 'initializeInputCodepage';
00140             $inpenc = $this->InputCharacterEncodingScheme;
00141             if ( $inpenc == 'singlebyte' )
00142             {
00143                 $isSinglebyteSame = true;
00144             }
00145             $isSame = true;
00146         }
00147         else if ( $useMBString and
00148                   isset( $mbStringCharsets[$this->InputCharsetCode] ) and
00149                   isset( $mbStringCharsets[$this->OutputCharsetCode] ) ) // Use MBString for converting if charsets supported
00150         {
00151             // NOTE:
00152             // The mbstringmapper object is no longer needed since all functionality is inlined
00153 //             $this->MBStringMapper = eZMBStringMapper::instance( $this->InputCharsetCode,
00154 //                                                                 $this->OutputCharsetCode );
00155             $conversionFunction = "convertMBString";
00156             $strlenFunction = "strlenMBString";
00157             $encodingConvertInitFunction = false;
00158         }
00159         else // See if we support encoding scheme and codepage
00160         {
00161             $inpenc = $this->InputCharacterEncodingScheme;
00162             $outenc = $this->OutputCharacterEncodingScheme;
00163             if ( isset( $encodingConvertMap[$inpenc][$outenc] ) )
00164             {
00165                 $conversionFunction = $encodingConvertMap[$inpenc][$outenc];
00166             }
00167         }
00168 
00169         if ( $strlenFunction === null )
00170         {
00171             $inpenc = $this->InputCharacterEncodingScheme;
00172             if ( $isSinglebyteSame )
00173             {
00174                 $strlenFunction = 'strlenNone';
00175             }
00176             else if ( $useMBString and isset( $mbStringCharsets[$this->InputCharsetCode] ) )
00177             {
00178                 $strlenFunction = 'strlenMBString';
00179             }
00180             else if ( isset( $encodingStrlenMap[$inpenc] ) )
00181             {
00182                 $strlenFunction = $encodingStrlenMap[$inpenc];
00183                 if ( $inpenc == 'utf-8')
00184                 {
00185                 }
00186             }
00187         }
00188 
00189         if ( !$isSame and
00190              $conversionFunction and
00191              $strlenFunction )
00192         {
00193             $this->initializeConversionFunction( $encodingConvertInitMap, $encodingConvertInitFunction );
00194         }
00195         if ( !$conversionFunction or
00196              !$strlenFunction )
00197         {
00198             eZDebug::writeError( "Cannot create textcodec from characterset " . $this->RequestedInputCharsetCode .
00199                                  " to characterset " . $this->RequestedOutputCharsetCode,
00200                                  "eZTextCodec" );
00201             if ( !$conversionFunction )
00202                 $conversionFunction = $noneConversionFunction;
00203             if ( !$strlenFunction )
00204                 $strlenFunction = $noneStrlenFunction;
00205         }
00206 
00207         $this->ConversionFunction = $conversionFunction;
00208         $this->StrlenFunction = $strlenFunction;
00209         $this->RequireConversion = $conversionFunction != $noneConversionFunction;
00210     }
00211 
00212     function initializeConversionFunction( $encodingConvertInitMap, $encodingConvertInitFunction )
00213     {
00214         $inpenc = $this->InputCharacterEncodingScheme;
00215         $outenc = $this->OutputCharacterEncodingScheme;
00216         $initFunction = false;
00217         if ( $encodingConvertInitFunction !== null )
00218         {
00219             if ( $encodingConvertInitFunction )
00220             {
00221                 $initFunction = $encodingConvertInitFunction;
00222             }
00223         }
00224         else if ( isset( $encodingConvertInitMap[$inpenc][$outenc] ) )
00225         {
00226             $initFunction = $encodingConvertInitMap[$inpenc][$outenc];
00227         }
00228         if ( $initFunction )
00229         {
00230             $this->$initFunction();
00231         }
00232     }
00233 
00234     function initializeCodepageMapper()
00235     {
00236         $this->CodepageMapper = eZCodePageMapper::instance( $this->InputCharsetCode,
00237                                                              $this->OutputCharsetCode );
00238     }
00239 
00240     function initializeInputCodepage()
00241     {
00242         $this->Codepage = eZCodePage::instance( $this->InputCharsetCode );
00243     }
00244 
00245     function initializeOutputCodepage()
00246     {
00247         $this->Codepage = eZCodePage::instance( $this->OutputCharsetCode );
00248     }
00249 
00250     /*!/
00251      \return true if a conversion is required, if false there's no need to call the textcodec functions.
00252     */
00253     function conversionRequired()
00254     {
00255         return $this->RequireConversion;
00256     }
00257 
00258     function setUseMBString( $use )
00259     {
00260         $GLOBALS["eZTextCodecUseMBString"] = $use;
00261     }
00262 
00263     function useMBString()
00264     {
00265         $use =& $GLOBALS["eZTextCodecUseMBString"];
00266         if ( !isset( $use ) )
00267             $use = true;
00268         return $use;
00269     }
00270 
00271     function requestedInputCharsetCode()
00272     {
00273         return $this->RequestedInputCharsetCode;
00274     }
00275 
00276     function requestedOutputCharsetCode()
00277     {
00278         return $this->RequestedOutputCharsetCode;
00279     }
00280 
00281     function inputCharsetCode()
00282     {
00283         return $this->InputCharsetCode;
00284     }
00285 
00286     function outputCharsetCode()
00287     {
00288         return $this->OutputCharsetCode;
00289     }
00290 
00291     function convertString( $str )
00292     {
00293         eZDebug::accumulatorStart( 'textcodec_conversion', false, 'String conversion' );
00294         //eZDebug::writeDebug( $this->ConversionFunction, 'conversion function' );
00295         $conversionFunction = $this->ConversionFunction;
00296         $tmp = $this->$conversionFunction( $str );
00297         eZDebug::accumulatorStop( 'textcodec_conversion' );
00298         return $tmp;
00299     }
00300 
00301     function strlen( $str )
00302     {
00303         $strlenFunction = $this->StrlenFunction;
00304         return $this->$strlenFunction( $str );
00305     }
00306 
00307     /*!
00308      \return an empty array since no conversion is possible.
00309     */
00310     function convertNoneToUnicode( $str )
00311     {
00312         return array();
00313     }
00314 
00315     function convertCodepageToUnicode( $str )
00316     {
00317         eZDebug::accumulatorStart( 'textcodec_codepage_unicode', false, 'String conversion w/ codepage to Unicode' );
00318         $tmp = $this->Codepage->convertStringToUnicode( $str );
00319         eZDebug::accumulatorStop( 'textcodec_codepage_unicode' );
00320         return $tmp;
00321     }
00322 
00323     function convertUTF8ToUnicode( $str )
00324     {
00325         eZDebug::accumulatorStart( 'textcodec_utf8_unicode', false, 'String conversion w/ UTF-8 to Unicode' );
00326         $tmp = eZUTF8Codec::convertStringToUnicode( $str );
00327         eZDebug::accumulatorStop( 'textcodec_utf8_unicode' );
00328         return $tmp;
00329     }
00330 
00331     function convertUnicodeToCodepage( $unicodeValues )
00332     {
00333         eZDebug::accumulatorStart( 'textcodec_unicode_codepage', false, 'String conversion w/ Unicode to codepage' );
00334         $tmp = $this->Codepage->convertUnicodeToString( $unicodeValues );
00335         eZDebug::accumulatorStop( 'textcodec_unicode_codepage' );
00336         return $tmp;
00337     }
00338 
00339     function convertUnicodeToUTF8( $unicodeValues )
00340     {
00341         eZDebug::accumulatorStart( 'textcodec_unicode_utf8', false, 'String conversion w/ Unicode to UTF8' );
00342         $tmp = eZUTF8Codec::convertUnicodeToString( $unicodeValues );
00343         eZDebug::accumulatorStop( 'textcodec_unicode_utf8' );
00344         return $tmp;
00345     }
00346 
00347     function convertNone( $str )
00348     {
00349         return $str;
00350     }
00351 
00352     function convertCodepage( $str )
00353     {
00354         eZDebug::accumulatorStart( 'textcodec_codepage', false, 'String conversion w/ codepage' );
00355         $tmp = $this->Codepage->convertString( $str );
00356         eZDebug::accumulatorStop( 'textcodec_codepage' );
00357         return $tmp;
00358     }
00359 
00360     function convertCodepageRev( $str )
00361     {
00362         eZDebug::accumulatorStart( 'textcodec_codepage_rev', false, 'String conversion w/ codepage reverse' );
00363         $tmp = $this->Codepage->convertStringFromUTF8( $str );
00364         eZDebug::accumulatorStop( 'textcodec_codepage_rev' );
00365         return $tmp;
00366     }
00367 
00368     function convertCodepageMapper( $str )
00369     {
00370         eZDebug::accumulatorStart( 'textcodec_codepage_mapper', false, 'String conversion w/ codepage mapper' );
00371         $tmp = $this->CodepageMapper->convertString( $str );
00372         eZDebug::accumulatorStop( 'textcodec_codepage_mapper' );
00373         return $tmp;
00374     }
00375 
00376     function convertMBString( $str )
00377     {
00378         eZDebug::accumulatorStart( 'textcodec_mbstring', false, 'String conversion w/ mbstring' );
00379 //        $tmp = $this->MBStringMapper->convertString( $str );
00380         // NOTE:
00381         // Uses the mbstring function directly instead of going trough the class
00382         $tmp = mb_convert_encoding( $str, $this->OutputCharsetCode, $this->InputCharsetCode );
00383         eZDebug::accumulatorStop( 'textcodec_mbstring' );
00384         return $tmp;
00385     }
00386 
00387     function strlenNone( $str )
00388     {
00389         return strlen( $str );
00390     }
00391 
00392     function strlenUnicode( $unicodeValues )
00393     {
00394         return count( $unicodeValues );
00395     }
00396 
00397     function strlenCodepage( $str )
00398     {
00399         return $this->Codepage->strlen( $str );
00400     }
00401 
00402     function strlenUTF8( $str )
00403     {
00404         $utf8_codec = eZUTF8Codec::instance();
00405         return $utf8_codec->strlen( $str );
00406     }
00407 
00408     function strlenCodepageRev( $str )
00409     {
00410         return $this->Codepage->strlenFromUTF8( $str );
00411     }
00412 
00413     function strlenCodepageMapper( $str )
00414     {
00415         return $this->CodepageMapper->strlen( $str );
00416     }
00417 
00418     function strlenMBString( $str )
00419     {
00420 //        return $this->MBStringMapper->strlen( $str );
00421         // NOTE:
00422         // Uses the mbstring function directly instead of going trough the class
00423         return mb_strlen( $str, $this->InputCharsetCode );
00424     }
00425 
00426     /**
00427      * Returns a shared instance of the eZTextCodec pr the
00428      * $inputCharsetCode and $outputCharsetCode params.
00429      *
00430      * @param string|false $inputCharsetCode Uses {@link eZTextCodec::internalCharset()} if false
00431      * @param string|false $outputCharsetCode Uses {@link eZTextCodec::internalCharset()} if false
00432      * @param bool $alwaysReturn
00433      * @return eZTextCodec|null Returns null if $alwaysReturn is false and text codec is not needed for
00434      *         current $inputCharsetCode and $outputCharsetCode.
00435      */
00436     static function instance( $inputCharsetCode, $outputCharsetCode = false, $alwaysReturn = true )
00437     {
00438         if ( $inputCharsetCode === false or $outputCharsetCode === false )
00439         {
00440             if ( isset( $GLOBALS['eZTextCodecInternalCharsetReal'] ) )
00441             {
00442                 $internalCharset = $GLOBALS['eZTextCodecInternalCharsetReal'];
00443             }
00444             else
00445             {
00446                 $internalCharset = eZTextCodec::internalCharset();
00447             }
00448         }
00449 
00450         if ( $inputCharsetCode === false )
00451         {
00452             $realInputCharsetCode = $inputCharsetCode = $internalCharset;
00453         }
00454         else
00455         {
00456             $realInputCharsetCode = eZCharsetInfo::realCharsetCode( $inputCharsetCode );
00457         }
00458 
00459         if ( $outputCharsetCode === false )
00460         {
00461             $realOutputCharsetCode = $outputCharsetCode = $internalCharset;
00462         }
00463         else
00464         {
00465             $realOutputCharsetCode = eZCharsetInfo::realCharsetCode( $outputCharsetCode );
00466         }
00467 
00468         $check =& $GLOBALS["eZTextCodecCharsetCheck"]["$realInputCharsetCode-$realOutputCharsetCode"];
00469         if ( !$alwaysReturn and isset( $check ) and !$check )
00470         {
00471             $check = null;
00472             return $check;
00473         }
00474         if ( isset( $check ) and is_object( $check ) )
00475         {
00476             return $check;
00477         }
00478 
00479         if ( !$realInputCharsetCode )
00480         {
00481             $realInputCharsetCode = eZCharsetInfo::realCharsetCode( $inputCharsetCode );
00482         }
00483         if ( !$realOutputCharsetCode )
00484         {
00485             $realOutputCharsetCode = eZCharsetInfo::realCharsetCode( $outputCharsetCode );
00486         }
00487         $inputEncoding = eZCharsetInfo::characterEncodingScheme( $realInputCharsetCode, true );
00488         $outputEncoding = eZCharsetInfo::characterEncodingScheme( $realOutputCharsetCode, true );
00489         if ( !$alwaysReturn and
00490              $inputEncoding == 'singlebyte' and
00491              $inputEncoding == $outputEncoding and
00492              $realInputCharsetCode == $realOutputCharsetCode )
00493         {
00494             $check = null;
00495             return $check;
00496         }
00497 
00498         $globalsKey = "eZTextCodec-$realInputCharsetCode-$realOutputCharsetCode";
00499         if ( !isset( $GLOBALS[$globalsKey] ) ||
00500              !( $GLOBALS[$globalsKey] instanceof eZTextCodec ) )
00501         {
00502             $GLOBALS[$globalsKey] = new eZTextCodec( $inputCharsetCode, $outputCharsetCode,
00503                                                      $realInputCharsetCode, $realOutputCharsetCode,
00504                                                      $inputEncoding, $outputEncoding );
00505         }
00506 
00507         $check = $GLOBALS[$globalsKey];
00508         return $GLOBALS[$globalsKey];
00509     }
00510 
00511     /*!
00512      \static
00513      Initializes the eZTextCodec settings to the ones in the array \a $settings.
00514      \sa internalCharset, httpCharset.
00515     */
00516     static function updateSettings( $settings )
00517     {
00518         unset( $GLOBALS['eZTextCodecInternalCharsetReal'] );
00519         unset( $GLOBALS['eZTextCodecHTTPCharsetReal'] );
00520         unset( $GLOBALS['eZTextCodecCharsetCheck'] );
00521         $GLOBALS['eZTextCodecInternalCharset'] = $settings['internal-charset'];
00522         $GLOBALS['eZTextCodecHTTPCharset'] = $settings['http-charset'];
00523         $GLOBALS['eZTextCodecMBStringExtension'] = $settings['mbstring-extension'];
00524         if ( function_exists( 'mb_internal_encoding' ) )
00525         {
00526             @mb_internal_encoding( $settings['internal-charset'] );
00527         }
00528     }
00529 
00530     /*!
00531      \static
00532      \return the charset which is used internally,
00533      this is the charset which all external files and resources are converted to.
00534      \note will return iso-8859-1 if eZTextCodec has been updated with proper settings.
00535     */
00536     static function internalCharset()
00537     {
00538         $realCharset =& $GLOBALS['eZTextCodecInternalCharsetReal'];
00539         if ( !isset( $realCharset ) )
00540         {
00541             if ( !isset( $GLOBALS['eZTextCodecInternalCharset'] ) )
00542             {
00543                 $i18n = eZINI::instance( 'i18n.ini', '', false );
00544                 $charsetCode = $i18n->variable( 'CharacterSettings', 'Charset' );
00545             }
00546             else
00547                 $charsetCode = $GLOBALS['eZTextCodecInternalCharset'];
00548             $realCharset = eZCharsetInfo::realCharsetCode( $charsetCode );
00549         }
00550         return $realCharset;
00551     }
00552 
00553     /*!
00554      \static
00555      \return a charset value which can be used in HTTP headers.
00556      \note Will return the internalCharset() if not http charset is set.
00557     */
00558     static function httpCharset()
00559     {
00560         $realCharset =& $GLOBALS['eZTextCodecHTTPCharsetReal'];
00561         if ( !isset( $realCharset ) )
00562         {
00563             $charset = '';
00564             if ( isset( $GLOBALS['eZTextCodecHTTPCharset'] ) )
00565                 $charset = $GLOBALS['eZTextCodecHTTPCharset'];
00566             if ( $charset == '' )
00567             {
00568                 if ( isset( $GLOBALS['eZTextCodecInternalCharsetReal'] ) )
00569                     $realCharset = $GLOBALS['eZTextCodecInternalCharsetReal'];
00570                 else
00571                     $realCharset = eZTextCodec::internalCharset();
00572             }
00573             else
00574             {
00575                 $realCharset = eZCharsetInfo::realCharsetCode( $charset );
00576             }
00577         }
00578         return $realCharset;
00579     }
00580 }
00581 
00582 ?>