102 $this->_charset = $charset;
103 $this->_charReader = null;
114 $this->_charReaderFactory = $factory;
122 $this->_datas = null;
124 $this->_charCount = 0;
125 $this->_currentPos = 0;
126 $this->_datasSize = 0;
139 while (
false !== ($read = $os->
read($blocks))) {
152 $this->
write($string);
164 if ($this->_currentPos >= $this->_charCount) {
169 ? $this->_charCount - $this->_currentPos
171 switch ($this->_mapType) {
174 $ret = substr($this->_datas,
175 $this->_currentPos * $this->_map,
177 $this->_currentPos += $length;
181 $end = $this->_currentPos + $length;
182 $end = $end > $this->_charCount
187 if (isset($this->_map[$this->_currentPos])) {
196 $end = $this->_currentPos + $length;
197 $end = $end > $this->_charCount
202 if ($this->_currentPos > 0) {
203 $start = $this->_map[
'p'][$this->_currentPos - 1];
207 if (isset($this->_map[
'i'][$this->_currentPos])) {
208 $ret .= substr($this->_datas, $start, $to - $start).
'?';
214 $ret .= substr($this->_datas, $start, $to - $start);
230 $read = $this->
read($length);
231 if ($read !==
false) {
232 $ret = array_map(
'ord', str_split($read, 1));
247 if ($this->_charCount < $charOffset) {
250 $this->_currentPos = $charOffset;
260 if (!isset($this->_charReader)) {
261 $this->_charReader = $this->_charReaderFactory->getReaderFor(
263 $this->_map = array();
264 $this->_mapType = $this->_charReader->getMapType();
267 $this->_datas .= $chars;
268 $this->_charCount += $this->_charReader->getCharPositions(substr($this->_datas, $this->_datasSize), $this->_datasSize, $this->_map, $ignored);
269 if ($ignored !==
false) {
270 $this->_datasSize = strlen($this->_datas) - strlen($ignored);
272 $this->_datasSize = strlen($this->_datas);