Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Iconv.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 6.49 KiB


001  <?php
002  /**
003   * Zend Framework (http://framework.zend.com/)
004   *
005   * @link      http://github.com/zendframework/zf2 for the canonical source repository
006   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
007   * @license   http://framework.zend.com/license/new-bsd New BSD License
008   */
009   
010  namespace Zend\Stdlib\StringWrapper;
011   
012  use Zend\Stdlib\Exception;
013   
014  class Iconv extends AbstractStringWrapper
015  {
016      /**
017       * List of supported character sets (upper case)
018       *
019       * @var string[]
020       * @link http://www.gnu.org/software/libiconv/
021       */
022      protected static $encodings = array(
023          // European languages
024          'ASCII',
025          'ISO-8859-1',
026          'ISO-8859-2',
027          'ISO-8859-3',
028          'ISO-8859-4',
029          'ISO-8859-5',
030          'ISO-8859-7',
031          'ISO-8859-9',
032          'ISO-8859-10',
033          'ISO-8859-13',
034          'ISO-8859-14',
035          'ISO-8859-15',
036          'ISO-8859-16',
037          'KOI8-R',
038          'KOI8-U',
039          'KOI8-RU',
040          'CP1250',
041          'CP1251',
042          'CP1252',
043          'CP1253',
044          'CP1254',
045          'CP1257',
046          'CP850',
047          'CP866',
048          'CP1131',
049          'MACROMAN',
050          'MACCENTRALEUROPE',
051          'MACICELAND',
052          'MACCROATIAN',
053          'MACROMANIA',
054          'MACCYRILLIC',
055          'MACUKRAINE',
056          'MACGREEK',
057          'MACTURKISH',
058          'MACINTOSH',
059   
060          // Semitic languages
061          'ISO-8859-6',
062          'ISO-8859-8',
063          'CP1255',
064          'CP1256',
065          'CP862',
066          'MACHEBREW',
067          'MACARABIC',
068   
069          // Japanese
070          'EUC-JP',
071          'SHIFT_JIS',
072          'CP932',
073          'ISO-2022-JP',
074          'ISO-2022-JP-2',
075          'ISO-2022-JP-1',
076   
077          // Chinese
078          'EUC-CN',
079          'HZ',
080          'GBK',
081          'CP936',
082          'GB18030',
083          'EUC-TW',
084          'BIG5',
085          'CP950',
086          'BIG5-HKSCS',
087          'BIG5-HKSCS:2004',
088          'BIG5-HKSCS:2001',
089          'BIG5-HKSCS:1999',
090          'ISO-2022-CN',
091          'ISO-2022-CN-EXT',
092   
093          // Korean
094          'EUC-KR',
095          'CP949',
096          'ISO-2022-KR',
097          'JOHAB',
098   
099          // Armenian
100          'ARMSCII-8',
101   
102          // Georgian
103          'GEORGIAN-ACADEMY',
104          'GEORGIAN-PS',
105   
106          // Tajik
107          'KOI8-T',
108   
109          // Kazakh
110          'PT154',
111          'RK1048',
112   
113          // Thai
114          'ISO-8859-11',
115          'TIS-620',
116          'CP874',
117          'MACTHAI',
118   
119          // Laotian
120          'MULELAO-1',
121          'CP1133',
122   
123          // Vietnamese
124          'VISCII',
125          'TCVN',
126          'CP1258',
127   
128          // Platform specifics
129          'HP-ROMAN8',
130          'NEXTSTEP',
131   
132          // Full Unicode
133          'UTF-8',
134          'UCS-2',
135          'UCS-2BE',
136          'UCS-2LE',
137          'UCS-4',
138          'UCS-4BE',
139          'UCS-4LE',
140          'UTF-16',
141          'UTF-16BE',
142          'UTF-16LE',
143          'UTF-32',
144          'UTF-32BE',
145          'UTF-32LE',
146          'UTF-7',
147          'C99',
148          'JAVA',
149   
150          /* Commented out because that's internal encodings not existing in real world
151          // Full Unicode, in terms of uint16_t or uint32_t (with machine dependent endianness and alignment)
152          'UCS-2-INTERNAL',
153          'UCS-4-INTERNAL',
154   
155          // Locale dependent, in terms of `char' or `wchar_t' (with machine dependent endianness and alignment,
156          // and with OS and locale dependent semantics)
157          'char',
158          'wchar_t',
159          '', // The empty encoding name is equivalent to "char": it denotes the locale dependent character encoding.
160          */
161   
162          // When configured with the option --enable-extra-encodings,
163          // it also provides support for a few extra encodings:
164   
165          // European languages
166          'CP437',
167          'CP737',
168          'CP775',
169          'CP852',
170          'CP853',
171          'CP855',
172          'CP857',
173          'CP858',
174          'CP860',
175          'CP861',
176          'CP863',
177          'CP865',
178          'CP869',
179          'CP1125',
180   
181          // Semitic languages
182          'CP864',
183   
184          // Japanese
185          'EUC-JISX0213',
186          'Shift_JISX0213',
187          'ISO-2022-JP-3',
188   
189          // Chinese
190          'BIG5-2003', // (experimental)
191   
192          // Turkmen
193          'TDS565',
194   
195          // Platform specifics
196          'ATARIST',
197          'RISCOS-LATIN1',
198      );
199   
200      /**
201       * Get a list of supported character encodings
202       *
203       * @return string[]
204       */
205      public static function getSupportedEncodings()
206      {
207          return static::$encodings;
208      }
209   
210      /**
211       * Constructor
212       *
213       * @throws Exception\ExtensionNotLoadedException
214       */
215      public function __construct()
216      {
217          if (!extension_loaded('iconv')) {
218              throw new Exception\ExtensionNotLoadedException(
219                  'PHP extension "iconv" is required for this wrapper'
220              );
221          }
222      }
223   
224      /**
225       * Returns the length of the given string
226       *
227       * @param string $str
228       * @return int|false
229       */
230      public function strlen($str)
231      {
232          return iconv_strlen($str, $this->getEncoding());
233      }
234   
235      /**
236       * Returns the portion of string specified by the start and length parameters
237       *
238       * @param string   $str
239       * @param int      $offset
240       * @param int|null $length
241       * @return string|false
242       */
243      public function substr($str, $offset = 0, $length = null)
244      {
245          return iconv_substr($str, $offset, $length, $this->getEncoding());
246      }
247   
248      /**
249       * Find the position of the first occurrence of a substring in a string
250       *
251       * @param string $haystack
252       * @param string $needle
253       * @param int    $offset
254       * @return int|false
255       */
256      public function strpos($haystack, $needle, $offset = 0)
257      {
258          return iconv_strpos($haystack, $needle, $offset, $this->getEncoding());
259      }
260   
261      /**
262       * Convert a string from defined encoding to the defined convert encoding
263       *
264       * @param string  $str
265       * @param bool $reverse
266       * @return string|false
267       */
268      public function convert($str, $reverse = false)
269      {
270          $encoding        = $this->getEncoding();
271          $convertEncoding = $this->getConvertEncoding();
272          if ($convertEncoding === null) {
273              throw new Exception\LogicException(
274                  'No convert encoding defined'
275              );
276          }
277   
278          if ($encoding === $convertEncoding) {
279              return $str;
280          }
281   
282          $fromEncoding = $reverse ? $convertEncoding : $encoding;
283          $toEncoding   = $reverse ? $encoding : $convertEncoding;
284   
285          // automatically add "//IGNORE" to not stop converting on invalid characters
286          // invalid characters triggers a notice anyway
287          return iconv($fromEncoding, $toEncoding . '//IGNORE', $str);
288      }
289  }
290