[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZCodePageCodec class 4 // 5 // Created on: <07-Mar-2002 10:19:23 amos> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! 30 \class eZCodePageCodec ezcodepagecodec.php 31 \ingroup eZI18N 32 \brief The class eZCodePageCodec does 33 34 */ 35 36 include_once ( "lib/ezi18n/classes/eztextcodec.php" ); 37 include_once ( "lib/ezi18n/classes/ezutf8codec.php" ); 38 39 class eZCodePageCodec extends eZTextCodec 40 { 41 /*! 42 Initializes the codepage codec with $name 43 */ 44 function eZCodePageCodec( $name ) 45 { 46 $this->eZTextCodec( $name ); 47 $this->CodePage = false; 48 } 49 50 function &toUnicode( $str ) 51 { 52 $ustr = ""; 53 if ( !is_string( $str ) or 54 !$this->isValid() ) 55 return $ustr; 56 $len = strlen( $str ); 57 for ( $i = 0; $i < $len; ++$i ) 58 { 59 // $char_code = $this->CodePage-> 60 // $ustr .= $this->toUtf8( $char_code ); 61 $char = $str[$i]; 62 $ustr .= $this->CodePage->charToUtf8( $char ); 63 } 64 return $ustr; 65 } 66 67 function &fromUnicode( $str ) 68 { 69 $ustr = ""; 70 if ( !is_string( $str ) or 71 !$this->isValid() ) 72 return $ustr; 73 $utf8_codec =& eZUTF8Codec::instance(); 74 $len = strlen( $str ); 75 for ( $i = 0; $i < $len; ) 76 { 77 $char_code = $utf8_codec->fromUtf8( $str, $i, $l ); 78 if ( $char_code !== false ) 79 { 80 $i += $l; 81 $ustr .= chr( $this->CodePage->unicodeToChar( $char_code ) ); 82 } 83 else 84 ++$i; 85 } 86 return $ustr; 87 } 88 89 /*! 90 Returns true if a codepage has been set. 91 */ 92 function isValid() 93 { 94 return get_class( $this->CodePage ) == "ezcodepage"; 95 } 96 97 /*! 98 Returns the codepage. 99 */ 100 function &codePage() 101 { 102 return $this->CodePage; 103 } 104 105 /*! 106 Sets the current codepage which is used for utf8/text translation. 107 */ 108 function setCodePage( &$cp ) 109 { 110 $this->CodePage =& $cp; 111 } 112 113 var $CodePage; 114 } 115 116 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |