Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezcodepagecodec.php
Go to the documentation of this file.
1 <?php
19 class eZCodePageCodec extends eZTextCodec
20 {
24 public function __construct( $name )
25 {
26 parent::__construct( $name );
27 $this->CodePage = false;
28 }
29
30 function toUnicode( $str )
31 {
32 $ustr = "";
33 if ( !is_string( $str ) or
34 !$this->isValid() )
35 return $ustr;
36 $len = strlen( $str );
37 for ( $i = 0; $i < $len; ++$i )
38 {
39 // $char_code = $this->CodePage->
40 // $ustr .= $this->toUtf8( $char_code );
41 $char = $str[$i];
42 $ustr .= $this->CodePage->charToUtf8( $char );
43 }
44 return $ustr;
45 }
46
47 function fromUnicode( $str )
48 {
49 $ustr = "";
50 if ( !is_string( $str ) or
51 !$this->isValid() )
52 return $ustr;
53 $utf8_codec = eZUTF8Codec::instance();
54 $len = strlen( $str );
55 for ( $i = 0; $i < $len; )
56 {
57 $char_code = $utf8_codec->fromUtf8( $str, $i, $l );
58 if ( $char_code !== false )
59 {
60 $i += $l;
61 $ustr .= chr( $this->CodePage->unicodeToChar( $char_code ) );
62 }
63 else
64 ++$i;
65 }
66 return $ustr;
67 }
68
72 function isValid()
73 {
74 return $this->CodePage instanceof eZCodePage;
75 }
76
80 function codePage()
81 {
82 return $this->CodePage;
83 }
84
88 function setCodePage( $cp )
89 {
90 $this->CodePage = $cp;
91 }
92
93 public $CodePage;
94 }
95
96 ?>
$i
$i
Definition: admin/adlist.php:91
eZCodePageCodec
The class eZCodePageCodec does.
Definition: ezcodepagecodec.php:20
eZCodePageCodec\setCodePage
setCodePage( $cp)
Definition: ezcodepagecodec.php:88
eZCodePageCodec\fromUnicode
fromUnicode( $str)
Definition: ezcodepagecodec.php:47
eZCodePageCodec\$CodePage
$CodePage
Definition: ezcodepagecodec.php:93
eZCodePageCodec\codePage
codePage()
Definition: ezcodepagecodec.php:80
eZCodePageCodec\__construct
__construct( $name)
Definition: ezcodepagecodec.php:24
eZCodePageCodec\toUnicode
toUnicode( $str)
Definition: ezcodepagecodec.php:30
eZCodePageCodec\isValid
isValid()
Definition: ezcodepagecodec.php:72
eZCodePage
Handles codepage files for charset mapping.
Definition: ezcodepage.php:20
eZTextCodec
Handles conversion from one charset to another.
Definition: ezi18n/classes/eztextcodec.php:24
eZTextCodec\strlen
strlen( $str)
Definition: ezi18n/classes/eztextcodec.php:312
eZUTF8Codec\instance
static instance()
Definition: ezutf8codec.php:240
$name
$name
Definition: companytypelist.php:194
$str
$str
Definition: ezarticle/modules/content.php:30
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.