42 $prefix =
'Swift_CharacterReader_';
45 'class' => $prefix .
'GenericFixedWidthReader',
46 'constructor' => array(1)
50 'class' => $prefix .
'GenericFixedWidthReader',
51 'constructor' => array(2)
55 'class' => $prefix .
'GenericFixedWidthReader',
56 'constructor' => array(4)
60 $this->_map[
'utf-?8'] = array(
61 'class' => $prefix .
'Utf8Reader',
62 'constructor' => array()
66 $this->_map[
'(us-)?ascii'] = $singleByte;
67 $this->_map[
'(iso|iec)-?8859-?[0-9]+'] = $singleByte;
68 $this->_map[
'windows-?125[0-9]'] = $singleByte;
69 $this->_map[
'cp-?[0-9]+'] = $singleByte;
70 $this->_map[
'ansi'] = $singleByte;
71 $this->_map[
'macintosh'] = $singleByte;
72 $this->_map[
'koi-?7'] = $singleByte;
73 $this->_map[
'koi-?8-?.+'] = $singleByte;
74 $this->_map[
'mik'] = $singleByte;
75 $this->_map[
'(cork|t1)'] = $singleByte;
76 $this->_map[
'v?iscii'] = $singleByte;
79 $this->_map[
'(ucs-?2|utf-?16)'] = $doubleByte;
82 $this->_map[
'(ucs-?4|utf-?32)'] = $fourBytes;
85 $this->_map[
'.*'] = $singleByte;
95 $charset = trim(strtolower($charset));
96 foreach ($this->_map as $pattern => $spec)
98 $re =
'/^' . $pattern .
'$/D';
99 if (preg_match($re, $charset))
101 if (!array_key_exists($pattern, $this->_loaded))
103 $reflector =
new ReflectionClass($spec[
'class']);
104 if ($reflector->getConstructor())
106 $reader = $reflector->newInstanceArgs($spec[
'constructor']);
110 $reader = $reflector->newInstance();
112 $this->_loaded[$pattern] = $reader;
114 return $this->_loaded[$pattern];