Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

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