Blame view

sources/3rdparty/phpdocx/classes/PhpdocxUtilities.inc 1.96 KB
31b7f2792   Kload   Upgrade to ownclo...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  <?php
  
  /**
   * PhpdocxUtilities
   *
   * @category   Phpdocx
   * @package    utilities
   * @copyright  Copyright (c) Narcea Producciones Multimedia S.L.
   *             (http://www.2mdc.com)
   * @license    LGPL
   * @version    3.0
   * @link       http://www.phpdocx.com
   * @since      File available since Release 3.0
   */
  
  class PhpdocxUtilities
  {
      /**
       *
       * @access public
       * @static
       * @var integer
       */
      private static $_phpdocxConfig;
  
      /**
       * Check if string is UTF8
       * 
       * @access public
       * @param string $string String to check
       * @static
       * @return boolean
       */
      public static function isUtf8($string_input)
      {
          $string = $string_input;
  
          $string = preg_replace("#[\x09\x0A\x0D\x20-\x7E]#", "", $string);
          $string = preg_replace("#[\xC2-\xDF][\x80-\xBF]#", "", $string);
          $string = preg_replace("#\xE0[\xA0-\xBF][\x80-\xBF]#", "", $string);
          $string = preg_replace("#[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}#", "", $string);
          $string = preg_replace("#\xED[\x80-\x9F][\x80-\xBF]#", "", $string);
          $string = preg_replace("#\xF0[\x90-\xBF][\x80-\xBF]{2}#", "", $string);
          $string = preg_replace("#[\xF1-\xF3][\x80-\xBF]{3}#", "", $string);
          $string = preg_replace("#\xF4[\x80-\x8F][\x80-\xBF]{2}#", "", $string);
  
          return ($string == ""?true:false); 
  
      }
  
      /**
       * Return a uniqueid to be used in tags
       *
       * @access public
       * @static
       * @return string
       */
      public static function parseConfig()
      {
          if (!isset(self::$_phpdocxConfig)) {
              self::$_phpdocxConfig = parse_ini_file(dirname(__FILE__) . '/../config/phpdocxconfig.ini', true);
          }
          return self::$_phpdocxConfig;
      }
  
      /**
       * Return a uniqueid to be used in tags
       *
       * @access public
       * @static
       * @return string
       */
      public static function uniqueId()
      {
          $uniqueid = uniqid('phpdocx_');
  
          return $uniqueid;
      }
  }