[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/ezi18n/classes/ -> eztextcodec.php (source)

   1  <?php
   2  //
   3  // Definition of eZTextCodec class
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  /*! \defgroup eZI18N Internationalization */
  28  
  29  /*!
  30    \class eZTextCodec eztextcodec.php
  31    \ingroup eZI18N
  32    \brief Handles conversion from one charset to another
  33  
  34    Supports <a href="http://www.ietf.org/rfc/rfc2279.txt">utf8</a> encoding/decoding
  35  
  36  */
  37  
  38  class eZTextCodec
  39  {
  40      /*!
  41      */
  42      function eZTextCodec( $inputCharsetCode, $outputCharsetCode,
  43                            $realInputCharsetCode, $realOutputCharsetCode,
  44                            $inputEncoding, $outputEncoding )
  45      {
  46          include_once ( "lib/ezi18n/classes/ezcharsetinfo.php" );
  47          $this->RequestedInputCharsetCode = $inputCharsetCode;
  48          $this->RequestedOutputCharsetCode = $outputCharsetCode;
  49          $this->InputCharsetCode = $realInputCharsetCode;
  50          $this->OutputCharsetCode = $realOutputCharsetCode;
  51          $this->InputCharacterEncodingScheme = $inputEncoding;
  52          $this->OutputCharacterEncodingScheme = $outputEncoding;
  53  
  54          $useMBStringExtension = false;
  55          if ( isset( $GLOBALS['eZTextCodecMBStringExtension'] ) )
  56              $useMBStringExtension = $GLOBALS['eZTextCodecMBStringExtension'];
  57  
  58          // NOTE:
  59          // The method eZMBStringMapper::hasMBStringExtension() has been copied and inlined here
  60          // Any modification must be reflected in the method
  61          $hasMBString = ( function_exists( "mb_convert_encoding" ) and
  62                           function_exists( "mb_substitute_character" ) and
  63                           function_exists( "mb_strcut" ) and
  64                           function_exists( "mb_strlen" ) and
  65                           function_exists( "mb_strpos" ) and
  66                           function_exists( "mb_strrpos" ) and
  67                           function_exists( "mb_strwidth" ) and
  68                           function_exists( "mb_substr" ) );
  69  
  70          $useMBString = ( $useMBStringExtension and
  71                           eZTextCodec::useMBString() and
  72                           $hasMBString );
  73  
  74          // Map for conversion functions using encoding functions
  75          $encodingConvertMap = array();
  76          $encodingConvertInitMap = array();
  77          $encodingStrlenMap = array();
  78  
  79          $encodingStrlenMap['unicode'] = 'strlenUnicode';
  80          $encodingStrlenMap['utf-8'] = 'strlenUTF8';
  81          $encodingStrlenMap['singlebyte'] = 'strlenCodepage';
  82          $encodingStrlenMap['doublebyte'] = 'strlenCodepage';
  83  
  84          // Unicode -> other
  85          $encodingConvertMap['unicode']['unicode'] = 'convertNone';
  86          $encodingConvertMap['unicode']['utf-8'] = 'convertUnicodeToUTF8';
  87          $encodingConvertMap['unicode']['singlebyte'] = 'convertUnicodeToCodepage';
  88          $encodingConvertMap['unicode']['doublebyte'] = 'convertUnicodeToCodepage';
  89  
  90          $encodingConvertInitMap['unicode']['singlebyte'] = 'initializeOutputCodepage';
  91          $encodingConvertInitMap['unicode']['doublebyte'] = 'initializeOutputCodepage';
  92  
  93          // UTF8 -> other
  94          $encodingConvertMap['utf-8']['unicode'] = 'convertUTF8ToUnicode';
  95          $encodingConvertMap['utf-8']['utf-8'] = 'convertNone';
  96          $encodingConvertMap['utf-8']['singlebyte'] = 'convertCodepageRev';
  97          $encodingConvertMap['utf-8']['doublebyte'] = 'convertCodepageRev';
  98  
  99          $encodingConvertInitMap['utf-8']['singlebyte'] = 'initializeOutputCodepage';
 100          $encodingConvertInitMap['utf-8']['doublebyte'] = 'initializeOutputCodepage';
 101  
 102          // singlebyte -> other
 103          $encodingConvertMap['singlebyte']['unicode'] = 'convertCodepageToUnicode';
 104          $encodingConvertMap['singlebyte']['utf-8'] = 'convertCodepage';
 105          $encodingConvertMap['singlebyte']['singlebyte'] = 'convertCodepageMapper';
 106          $encodingConvertMap['singlebyte']['doublebyte'] = 'convertCodepageMapper';
 107  
 108          $encodingConvertInitMap['singlebyte']['unicode'] = 'initializeInputCodepage';
 109          $encodingConvertInitMap['singlebyte']['utf-8'] = 'initializeInputCodepage';
 110          $encodingConvertInitMap['singlebyte']['singlebyte'] = 'initializeCodepageMapper';
 111          $encodingConvertInitMap['singlebyte']['doublebyte'] = 'initializeCodepageMapper';
 112  
 113          // doublebyte -> other
 114          $encodingConvertMap['doublebyte']['unicode'] = 'convertCodepageToUnicode';
 115          $encodingConvertMap['doublebyte']['utf-8'] = 'convertCodepage';
 116          $encodingConvertMap['doublebyte']['singlebyte'] = 'convertCodepageMapper';
 117          $encodingConvertMap['doublebyte']['doublebyte'] = 'convertCodepageMapper';
 118  
 119          $encodingConvertInitMap['doublebyte']['unicode'] = 'initializeInputCodepage';
 120          $encodingConvertInitMap['doublebyte']['utf-8'] = 'initializeInputCodepage';
 121          $encodingConvertInitMap['doublebyte']['singlebyte'] = 'initializeCodepageMapper';
 122          $encodingConvertInitMap['doublebyte']['doublebyte'] = 'convertCodepageMapper';
 123  
 124  
 125          $noneConversionFunction = 'convertNone';
 126          $noneStrlenFunction = 'strlenNone';
 127          $conversionFunction = null;
 128          $strlenFunction = null;
 129          $encodingConvertInitFunction = null;
 130  
 131          // NOTE:
 132          // The method eZMBStringMapper::charsetList() hash been copied and inlined here
 133          // Any modification must be reflected in the method
 134          $mbStringCharsets =& $GLOBALS["eZMBCharsetList"];
 135          if ( $useMBString and
 136               !is_array( $mbStringCharsets ) )
 137          {
 138              $charsetList = array( "ucs-4", "ucs-4be", "ucs-4le", "ucs-2", "ucs-2be", "ucs-2le", "utf-32", "utf-32be", "utf-32le", "utf-16",
 139                                    "utf-16be", "utf-16le", "utf-8", "utf-7", "ascii", "euc-jp", "sjis", "eucjp-win", "sjis-win", "iso-2022-jp", "jis",
 140                                    "iso-8859-1", "iso-8859-2", "iso-8859-3", "iso-8859-4", "iso-8859-5", "iso-8859-6", "iso-8859-7", "iso-8859-8",
 141                                    "iso-8859-9", "iso-8859-10", "iso-8859-13", "iso-8859-14", "iso-8859-15", "byte2be", "byte2le", "byte4be",
 142                                    "byte4le", "base64", "7bit", "8bit", "utf7-imap" );
 143              $mbStringCharsets = array();
 144              foreach ( $charsetList as $charset )
 145              {
 146                  $mbStringCharsets[$charset] = $charset;
 147              }
 148          }
 149  
 150          // Is to true if the charsets are the same and they have singlebyte encoding
 151          $isSinglebyteSame = false;
 152          $isSame = false;
 153  
 154          // First detect conversion type
 155          if ( $this->InputCharsetCode == $this->OutputCharsetCode ) // Direct match, no conversion
 156          {
 157              $conversionFunction = $noneConversionFunction;
 158              $encodingConvertInitFunction = 'initializeInputCodepage';
 159              $inpenc = $this->InputCharacterEncodingScheme;
 160              if ( $inpenc == 'singlebyte' )
 161              {
 162                  $isSinglebyteSame = true;
 163              }
 164              $isSame = true;
 165          }
 166          else if ( $useMBString and
 167                    isset( $mbStringCharsets[$this->InputCharsetCode] ) and
 168                    isset( $mbStringCharsets[$this->OutputCharsetCode] ) ) // Use MBString for converting if charsets supported
 169          {
 170              // NOTE:
 171              // The mbstringmapper object is no longer needed since all functionality is inlined
 172  //             $this->MBStringMapper = eZMBStringMapper::instance( $this->InputCharsetCode,
 173  //                                                                 $this->OutputCharsetCode );
 174              $conversionFunction = "convertMBString";
 175              $strlenFunction = "strlenMBString";
 176              $encodingConvertInitFunction = false;
 177          }
 178          else // See if we support encoding scheme and codepage
 179          {
 180              $inpenc = $this->InputCharacterEncodingScheme;
 181              $outenc = $this->OutputCharacterEncodingScheme;
 182              if ( isset( $encodingConvertMap[$inpenc][$outenc] ) )
 183              {
 184                  $conversionFunction = $encodingConvertMap[$inpenc][$outenc];
 185              }
 186          }
 187  
 188          if ( $strlenFunction === null )
 189          {
 190              $inpenc = $this->InputCharacterEncodingScheme;
 191              if ( $isSinglebyteSame )
 192              {
 193                  $strlenFunction = 'strlenNone';
 194              }
 195              else if ( $useMBString and isset( $mbStringCharsets[$this->InputCharsetCode] ) )
 196              {
 197                  $strlenFunction = 'strlenMBString';
 198              }
 199              else if ( isset( $encodingStrlenMap[$inpenc] ) )
 200              {
 201                  $strlenFunction = $encodingStrlenMap[$inpenc];
 202                  if ( $inpenc == 'utf-8')
 203                  {
 204                      include_once ( "lib/ezi18n/classes/ezutf8codec.php" );
 205                  }
 206              }
 207          }
 208  
 209          if ( !$isSame and
 210               $conversionFunction and
 211               $strlenFunction )
 212          {
 213              $this->initializeConversionFunction( $encodingConvertInitMap, $encodingConvertInitFunction );
 214          }
 215          if ( !$conversionFunction or
 216               !$strlenFunction )
 217          {
 218              eZDebug::writeError( "Cannot create textcodec from characterset " . $this->RequestedInputCharsetCode .
 219                                   " to characterset " . $this->RequestedOutputCharsetCode,
 220                                   "eZTextCodec" );
 221              if ( !$conversionFunction )
 222                  $conversionFunction = $noneConversionFunction;
 223              if ( !$strlenFunction )
 224                  $strlenFunction = $noneStrlenFunction;
 225          }
 226  
 227          $this->ConversionFunction = $conversionFunction;
 228          $this->StrlenFunction = $strlenFunction;
 229          $this->RequireConversion = $conversionFunction != $noneConversionFunction;
 230      }
 231  
 232      function initializeConversionFunction( $encodingConvertInitMap, $encodingConvertInitFunction )
 233      {
 234          $inpenc = $this->InputCharacterEncodingScheme;
 235          $outenc = $this->OutputCharacterEncodingScheme;
 236          $initFunction = false;
 237          if ( $encodingConvertInitFunction !== null )
 238          {
 239              if ( $encodingConvertInitFunction )
 240              {
 241                  $initFunction = $encodingConvertInitFunction;
 242              }
 243          }
 244          else if ( isset( $encodingConvertInitMap[$inpenc][$outenc] ) )
 245          {
 246              $initFunction = $encodingConvertInitMap[$inpenc][$outenc];
 247          }
 248          if ( $initFunction )
 249          {
 250              $this->$initFunction();
 251          }
 252      }
 253  
 254      function initializeCodepageMapper()
 255      {
 256          include_once ( 'lib/ezi18n/classes/ezcodepagemapper.php' );
 257          $this->CodepageMapper =& eZCodepageMapper::instance( $this->InputCharsetCode,
 258                                                               $this->OutputCharsetCode );
 259      }
 260  
 261      function initializeInputCodepage()
 262      {
 263          include_once ( 'lib/ezi18n/classes/ezcodepage.php' );
 264          $this->Codepage =& eZCodepage::instance( $this->InputCharsetCode );
 265      }
 266  
 267      function initializeOutputCodepage()
 268      {
 269          include_once ( 'lib/ezi18n/classes/ezcodepage.php' );
 270          $this->Codepage =& eZCodepage::instance( $this->OutputCharsetCode );
 271      }
 272  
 273      /*!/
 274       \return true if a conversion is required, if false there's no need to call the textcodec functions.
 275      */
 276      function conversionRequired()
 277      {
 278          return $this->RequireConversion;
 279      }
 280  
 281      function setUseMBString( $use )
 282      {
 283          $GLOBALS["eZTextCodecUseMBString"] = $use;
 284      }
 285  
 286      function useMBString()
 287      {
 288          $use =& $GLOBALS["eZTextCodecUseMBString"];
 289          if ( !isset( $use ) )
 290              $use = true;
 291          return $use;
 292      }
 293  
 294      function requestedInputCharsetCode()
 295      {
 296          return $this->RequestedInputCharsetCode;
 297      }
 298  
 299      function requestedOutputCharsetCode()
 300      {
 301          return $this->RequestedOutputCharsetCode;
 302      }
 303  
 304      function inputCharsetCode()
 305      {
 306          return $this->InputCharsetCode;
 307      }
 308  
 309      function outputCharsetCode()
 310      {
 311          return $this->OutputCharsetCode;
 312      }
 313  
 314      function convertString( $str )
 315      {
 316          eZDebug::accumulatorStart( 'textcodec_conversion', false, 'String conversion' );
 317          $conversionFunction = $this->ConversionFunction;
 318          $tmp = $this->$conversionFunction( $str );
 319          eZDebug::accumulatorStop( 'textcodec_conversion' );
 320          return $tmp;
 321      }
 322  
 323      function strlen( $str )
 324      {
 325          $strlenFunction = $this->StrlenFunction;
 326          return $this->$strlenFunction( $str );
 327      }
 328  
 329      /*!
 330       \return an empty array since no conversion is possible.
 331      */
 332      function convertNoneToUnicode( $str )
 333      {
 334          return array();
 335      }
 336  
 337      function convertCodepageToUnicode( $str )
 338      {
 339          eZDebug::accumulatorStart( 'textcodec_codepage_unicode', false, 'String conversion w/ codepage to Unicode' );
 340          $tmp = $this->Codepage->convertStringToUnicode( $str );
 341          eZDebug::accumulatorStop( 'textcodec_codepage_unicode' );
 342          return $tmp;
 343      }
 344  
 345      function convertUTF8ToUnicode( $str )
 346      {
 347          include_once  ( 'lib/ezi18n/classes/ezutf8codec.php' );
 348          eZDebug::accumulatorStart( 'textcodec_utf8_unicode', false, 'String conversion w/ UTF-8 to Unicode' );
 349          $tmp = eZUTF8Codec::convertStringToUnicode( $str );
 350          eZDebug::accumulatorStop( 'textcodec_utf8_unicode' );
 351          return $tmp;
 352      }
 353  
 354      function convertUnicodeToCodepage( $unicodeValues )
 355      {
 356          eZDebug::accumulatorStart( 'textcodec_unicode_codepage', false, 'String conversion w/ Unicode to codepage' );
 357          $tmp = $this->Codepage->convertUnicodeToString( $unicodeValues );
 358          eZDebug::accumulatorStop( 'textcodec_unicode_codepage' );
 359          return $tmp;
 360      }
 361  
 362      function convertUnicodeToUTF8( $unicodeValues )
 363      {
 364          include_once  ( 'lib/ezi18n/classes/ezutf8codec.php' );
 365          eZDebug::accumulatorStart( 'textcodec_unicode_utf8', false, 'String conversion w/ Unicode to UTF8' );
 366          $tmp = eZUTF8Codec::convertUnicodeToString( $unicodeValues );
 367          eZDebug::accumulatorStop( 'textcodec_unicode_utf8' );
 368          return $tmp;
 369      }
 370  
 371      function convertNone( $str )
 372      {
 373          return $str;
 374      }
 375  
 376      function convertCodepage( $str )
 377      {
 378          eZDebug::accumulatorStart( 'textcodec_codepage', false, 'String conversion w/ codepage' );
 379          $tmp = $this->Codepage->convertString( $str );
 380          eZDebug::accumulatorStop( 'textcodec_codepage', false, 'String conversion w/ codepage' );
 381          return $tmp;
 382      }
 383  
 384      function convertCodepageRev( $str )
 385      {
 386          eZDebug::accumulatorStart( 'textcodec_codepage_rev', false, 'String conversion w/ codepage reverse' );
 387          $tmp = $this->Codepage->convertStringFromUTF8( $str );
 388          eZDebug::accumulatorStop( 'textcodec_codepage_rev', false, 'String conversion w/ codepage reverse' );
 389          return $tmp;
 390      }
 391  
 392      function convertCodepageMapper( $str )
 393      {
 394          eZDebug::accumulatorStart( 'textcodec_codepage_mapper', false, 'String conversion w/ codepage mapper' );
 395          $tmp = $this->CodepageMapper->convertString( $str );
 396          eZDebug::accumulatorStop( 'textcodec_codepage_mapper', false, 'String conversion w/ codepage mapper' );
 397          return $tmp;
 398      }
 399  
 400      function convertMBString( $str )
 401      {
 402          eZDebug::accumulatorStart( 'textcodec_mbstring', false, 'String conversion w/ mbstring' );
 403  //        $tmp = $this->MBStringMapper->convertString( $str );
 404          // NOTE:
 405          // Uses the mbstring function directly instead of going trough the class
 406          $tmp = mb_convert_encoding( $str, $this->OutputCharsetCode, $this->InputCharsetCode );
 407          eZDebug::accumulatorStop( 'textcodec_mbstring', false, 'String conversion w/ mbstring' );
 408          return $tmp;
 409      }
 410  
 411      function strlenNone( $str )
 412      {
 413          return strlen( $str );
 414      }
 415  
 416      function strlenUnicode( $unicodeValues )
 417      {
 418          return count( $unicodeValues );
 419      }
 420  
 421      function strlenCodepage( $str )
 422      {
 423          return $this->Codepage->strlen( $str );
 424      }
 425  
 426      function strlenUTF8( $str )
 427      {
 428          $utf8_codec =& eZUTF8Codec::instance();
 429          return $utf8_codec->strlen( $str );
 430      }
 431  
 432      function strlenCodepageRev( $str )
 433      {
 434          return $this->Codepage->strlenFromUTF8( $str );
 435      }
 436  
 437      function strlenCodepageMapper( $str )
 438      {
 439          return $this->CodepageMapper->strlen( $str );
 440      }
 441  
 442      function strlenMBString( $str )
 443      {
 444  //        return $this->MBStringMapper->strlen( $str );
 445          // NOTE:
 446          // Uses the mbstring function directly instead of going trough the class
 447          return mb_strlen( $str, $this->InputCharsetCode );
 448      }
 449  
 450      /*!
 451       \static
 452       \return a text codec instance which can be used to convert from input charset \a $inputCharsetCode
 453               and into output charset \a $outputCharsetCode.
 454       \param $inputCharsetCode If \c false the internal charset it used, otherwise it is used directly
 455       \param $outputCharsetCode If \c false the internal charset it used, otherwise it is used directly
 456       \param $alwaysReturn If \c false it will only return a textcodec instance if it is required for the input and output charset.
 457                            In which case it returns \c null.
 458      */
 459      function &instance( $inputCharsetCode, $outputCharsetCode = false, $alwaysReturn = true )
 460      {
 461          if ( $inputCharsetCode === false or $outputCharsetCode === false )
 462          {
 463              if ( isset( $GLOBALS['eZTextCodecInternalCharsetReal'] ) )
 464              {
 465                  $internalCharset = $GLOBALS['eZTextCodecInternalCharsetReal'];
 466              }
 467              else
 468              {
 469                  $internalCharset = eZTextCodec::internalCharset();
 470              }
 471          }
 472  
 473          if ( $inputCharsetCode === false )
 474          {
 475              $realInputCharsetCode = $inputCharsetCode = $internalCharset;
 476          }
 477          else
 478          {
 479              $realInputCharsetCode = eZCharsetInfo::realCharsetCode( $inputCharsetCode );
 480          }
 481  
 482          if ( $outputCharsetCode === false )
 483          {
 484              $realOutputCharsetCode = $outputCharsetCode = $internalCharset;
 485          }
 486          else
 487          {
 488              $realOutputCharsetCode = eZCharsetInfo::realCharsetCode( $outputCharsetCode );
 489          }
 490  
 491          $check =& $GLOBALS["eZTextCodecCharsetCheck"]["$realInputCharsetCode-$realOutputCharsetCode"];
 492          if ( !$alwaysReturn and isset( $check ) and !$check )
 493          {
 494              $check = null;
 495              return $check;
 496          }
 497          if ( isset( $check ) and is_object( $check ) )
 498          {
 499              return $check;
 500          }
 501  
 502          if ( !$realInputCharsetCode )
 503          {
 504              include_once ( "lib/ezi18n/classes/ezcharsetinfo.php" );
 505              $realInputCharsetCode = eZCharsetInfo::realCharsetCode( $inputCharsetCode );
 506          }
 507          if ( !$realOutputCharsetCode )
 508          {
 509              include_once ( "lib/ezi18n/classes/ezcharsetinfo.php" );
 510              $realOutputCharsetCode = eZCharsetInfo::realCharsetCode( $outputCharsetCode );
 511          }
 512          $inputEncoding = eZCharsetInfo::characterEncodingScheme( $realInputCharsetCode, true );
 513          $outputEncoding = eZCharsetInfo::characterEncodingScheme( $realOutputCharsetCode, true );
 514          if ( !$alwaysReturn and
 515               $inputEncoding == 'singlebyte' and
 516               $inputEncoding == $outputEncoding and
 517               $realInputCharsetCode == $realOutputCharsetCode )
 518          {
 519              $check = null;
 520              return $check;
 521          }
 522          $codec =& $GLOBALS["eZTextCodec-$realInputCharsetCode-$realOutputCharsetCode"];
 523          if ( get_class( $codec ) != "eztextcodec" )
 524          {
 525              $codec = new eZTextCodec( $inputCharsetCode, $outputCharsetCode,
 526                                        $realInputCharsetCode, $realOutputCharsetCode,
 527                                        $inputEncoding, $outputEncoding );
 528          }
 529          $check =& $codec;
 530          return $codec;
 531      }
 532  
 533      /*!
 534       \static
 535       Initializes the eZTextCodec settings to the ones in the array \a $settings.
 536       \sa internalCharset, httpCharset.
 537      */
 538      function updateSettings( $settings )
 539      {
 540          unset( $GLOBALS['eZTextCodecInternalCharsetReal'] );
 541          unset( $GLOBALS['eZTextCodecHTTPCharsetReal'] );
 542          unset( $GLOBALS['eZTextCodecCharsetCheck'] );
 543          $GLOBALS['eZTextCodecInternalCharset'] = $settings['internal-charset'];
 544          $GLOBALS['eZTextCodecHTTPCharset'] = $settings['http-charset'];
 545          $GLOBALS['eZTextCodecMBStringExtension'] = $settings['mbstring-extension'];
 546          if ( function_exists( 'mb_internal_encoding' ) )
 547          {
 548              @mb_internal_encoding( $settings['internal-charset'] );
 549          }
 550      }
 551  
 552      /*!
 553       \static
 554       \return the charset which is used internally,
 555       this is the charset which all external files and resources are converted to.
 556       \note will return iso-8859-1 if eZTextCodec has been updated with proper settings.
 557      */
 558      function internalCharset()
 559      {
 560          $realCharset =& $GLOBALS['eZTextCodecInternalCharsetReal'];
 561          if ( !isset( $realCharset ) )
 562          {
 563              if ( !isset( $GLOBALS['eZTextCodecInternalCharset'] ) )
 564                  $charsetCode = 'iso-8859-1';
 565              else
 566                  $charsetCode = $GLOBALS['eZTextCodecInternalCharset'];
 567              include_once ( "lib/ezi18n/classes/ezcharsetinfo.php" );
 568              $realCharset = eZCharsetInfo::realCharsetCode( $charsetCode );
 569          }
 570          return $realCharset;
 571      }
 572  
 573      /*!
 574       \static
 575       \return a charset value which can be used in HTTP headers.
 576       \note Will return the internalCharset() if not http charset is set.
 577      */
 578      function httpCharset()
 579      {
 580          $realCharset =& $GLOBALS['eZTextCodecHTTPCharsetReal'];
 581          if ( !isset( $realCharset ) )
 582          {
 583              $charset = '';
 584              if ( isset( $GLOBALS['eZTextCodecHTTPCharset'] ) )
 585                  $charset = $GLOBALS['eZTextCodecHTTPCharset'];
 586              if ( $charset == '' )
 587              {
 588                  if ( isset( $GLOBALS['eZTextCodecInternalCharsetReal'] ) )
 589                      $realCharset = $GLOBALS['eZTextCodecInternalCharsetReal'];
 590                  else
 591                      $realCharset = eZTextCodec::internalCharset();
 592              }
 593              else
 594              {
 595                  include_once ( "lib/ezi18n/classes/ezcharsetinfo.php" );
 596                  $realCharset = eZCharsetInfo::realCharsetCode( $charset );
 597              }
 598          }
 599          return $realCharset;
 600      }
 601  }
 602  
 603  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7