Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

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

unicode_testing.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 2.68 KiB


001  <?php
002  //
003  // This file provides some useful functions for debugging the unicode/UTF-8 library
004  // It requires utf_tools.php to be loaded
005  //
006  die("Please read the first lines of this script for instructions on how to enable it");
007   
008  if (!headers_sent())
009  {
010      header('Content-type: text/html; charset=UTF-8');
011  }
012   
013  /**
014   * Converts unicode escape sequences (\u0123) into UTF-8 characters
015   *
016   * @param    string    A unicode sequence
017   * @return    string    UTF-8 representation of the given unicode sequence
018   */
019  function unicode_to_utf8($string)
020  {
021      $utf8 = '';
022      $chars = array();
023      for ($i = 0; $i < strlen($string); $i++)
024      {
025          if (isset($string[$i + 5]) && substr($string, $i, 2) == '\\u' && ctype_xdigit(substr($string, $i + 2, 4)))
026          {
027              $utf8 .= utf8_from_unicode(array(base_convert(substr($string, $i + 2, 4), 16, 10)));
028              $i += 5;
029          }
030          else
031          {
032              $utf8 .= $string[$i];
033          }
034      }
035      return $utf8;
036  }
037   
038  /**
039   * Takes an array of ints representing the Unicode characters and returns
040   * a UTF-8 string.
041   *
042   * @param array $array array of unicode code points representing a string
043   * @return string UTF-8 character string
044   */
045  function utf8_from_unicode($array)
046  {
047      $str = '';
048      foreach ($array as $value)
049      {
050          $str .= utf8_chr($value);
051      }
052      return $str;
053  }
054   
055  /**
056  * Converts a UTF-8 string to unicode code points
057  *
058  * @param    string    $text        UTF-8 string
059  * @return    string                Unicode code points
060  */
061  function utf8_to_unicode($text)
062  {
063      return preg_replace_callback(
064          '#[\\xC2-\\xF4][\\x80-\\xBF]?[\\x80-\\xBF]?[\\x80-\\xBF]#',
065          'utf8_to_unicode_callback',
066          preg_replace_callback(
067              '#[\\x00-\\x7f]#',
068              'utf8_to_unicode_callback',
069              $text
070          )
071      );
072  }
073   
074  /**
075  * Takes a UTF-8 char and replaces it with its unicode escape sequence. Attention, $m is an array
076  *
077  * @param    array    $m            0-based numerically indexed array passed by preg_replace_callback()
078  * @return    string                A unicode escape sequence
079  */
080  function utf8_to_unicode_callback($m)
081  {
082      return '\u' . str_pad(base_convert(utf8_ord($m[0]), 10, 16), 4, '0', STR_PAD_LEFT) . '';
083  }
084   
085  /**
086  * A wrapper function for the normalizer which takes care of including the class if required and modifies the passed strings
087  * to be in NFKC
088  *
089  * @param    mixed    $strings    a string or an array of strings to normalize
090  * @return    mixed                the normalized content, preserving array keys if array given.
091  */
092  function utf8_normalize_nfkc($strings)
093  {
094      if (empty($strings))
095      {
096          return $strings;
097      }
098   
099      if (!class_exists('utf_normalizer'))
100      {
101          global $phpbb_root_path, $phpEx;
102          include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx);
103      }
104   
105      if (!is_array($strings))
106      {
107          utf_normalizer::nfkc($strings);
108      }
109      else if (is_array($strings))
110      {
111          foreach ($strings as $key => $string)
112          {
113              utf_normalizer::nfkc($strings[$key]);
114          }
115      }
116   
117      return $strings;
118  }
119   
120  ?>