PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php +706 -714 3.1.23.0.10 View file →
@@ -1,10 +1,9 @@
1 1 <?php
2 -
3 2 /**
4 - * PHPExcel_Shared_String
3 + * PHPExcel
5 4 *
6 - * Copyright (c) 2006 - 2015 PHPExcel
5 + * Copyright (c) 2006 - 2014 PHPExcel
7 6 *
8 7 * This library is free software; you can redistribute it and/or
9 8 * modify it under the terms of the GNU Lesser General Public
10 9 * License as published by the Free Software Foundation; either
@@ -20,618 +19,613 @@
20 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 20 *
22 21 * @category PHPExcel
23 22 * @package PHPExcel_Shared
24 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
25 - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
23 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
26 25 * @version ##VERSION##, ##DATE##
27 26 */
27 +
28 +
29 +/**
30 + * PHPExcel_Shared_String
31 + *
32 + * @category PHPExcel
33 + * @package PHPExcel_Shared
34 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 + */
28 36 class PHPExcel_Shared_String
29 37 {
30 - /** Constants */
31 - /** Regular Expressions */
32 - // Fraction
33 - const STRING_REGEXP_FRACTION = '(-?)(\d+)\s+(\d+\/\d+)';
38 + /** Constants */
39 + /** Regular Expressions */
40 + // Fraction
41 + const STRING_REGEXP_FRACTION = '(-?)(\d+)\s+(\d+\/\d+)';
34 42
35 43
36 - /**
37 - * Control characters array
38 - *
39 - * @var string[]
40 - */
41 - private static $controlCharacters = array();
44 + /**
45 + * Control characters array
46 + *
47 + * @var string[]
48 + */
49 + private static $_controlCharacters = array();
42 50
43 - /**
44 - * SYLK Characters array
45 - *
46 - * $var array
47 - */
48 - private static $SYLKCharacters = array();
51 + /**
52 + * SYLK Characters array
53 + *
54 + * $var array
55 + */
56 + private static $_SYLKCharacters = array();
49 57
50 - /**
51 - * Decimal separator
52 - *
53 - * @var string
54 - */
55 - private static $decimalSeparator;
58 + /**
59 + * Decimal separator
60 + *
61 + * @var string
62 + */
63 + private static $_decimalSeparator;
56 64
57 - /**
58 - * Thousands separator
59 - *
60 - * @var string
61 - */
62 - private static $thousandsSeparator;
65 + /**
66 + * Thousands separator
67 + *
68 + * @var string
69 + */
70 + private static $_thousandsSeparator;
63 71
64 - /**
65 - * Currency code
66 - *
67 - * @var string
68 - */
69 - private static $currencyCode;
72 + /**
73 + * Currency code
74 + *
75 + * @var string
76 + */
77 + private static $_currencyCode;
70 78
71 - /**
72 - * Is mbstring extension avalable?
73 - *
74 - * @var boolean
75 - */
76 - private static $isMbstringEnabled;
79 + /**
80 + * Is mbstring extension avalable?
81 + *
82 + * @var boolean
83 + */
84 + private static $_isMbstringEnabled;
77 85
78 - /**
79 - * Is iconv extension avalable?
80 - *
81 - * @var boolean
82 - */
83 - private static $isIconvEnabled;
86 + /**
87 + * Is iconv extension avalable?
88 + *
89 + * @var boolean
90 + */
91 + private static $_isIconvEnabled;
84 92
85 - /**
86 - * Build control characters array
87 - */
88 - private static function buildControlCharacters()
89 - {
90 - for ($i = 0; $i <= 31; ++$i) {
91 - if ($i != 9 && $i != 10 && $i != 13) {
92 - $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
93 - $replace = chr($i);
94 - self::$controlCharacters[$find] = $replace;
95 - }
96 - }
97 - }
93 + /**
94 + * Build control characters array
95 + */
96 + private static function _buildControlCharacters() {
97 + for ($i = 0; $i <= 31; ++$i) {
98 + if ($i != 9 && $i != 10 && $i != 13) {
99 + $find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
100 + $replace = chr($i);
101 + self::$_controlCharacters[$find] = $replace;
102 + }
103 + }
104 + }
98 105
99 - /**
100 - * Build SYLK characters array
101 - */
102 - private static function buildSYLKCharacters()
103 - {
104 - self::$SYLKCharacters = array(
105 - "\x1B 0" => chr(0),
106 - "\x1B 1" => chr(1),
107 - "\x1B 2" => chr(2),
108 - "\x1B 3" => chr(3),
109 - "\x1B 4" => chr(4),
110 - "\x1B 5" => chr(5),
111 - "\x1B 6" => chr(6),
112 - "\x1B 7" => chr(7),
113 - "\x1B 8" => chr(8),
114 - "\x1B 9" => chr(9),
115 - "\x1B :" => chr(10),
116 - "\x1B ;" => chr(11),
117 - "\x1B <" => chr(12),
118 - "\x1B :" => chr(13),
119 - "\x1B >" => chr(14),
120 - "\x1B ?" => chr(15),
121 - "\x1B!0" => chr(16),
122 - "\x1B!1" => chr(17),
123 - "\x1B!2" => chr(18),
124 - "\x1B!3" => chr(19),
125 - "\x1B!4" => chr(20),
126 - "\x1B!5" => chr(21),
127 - "\x1B!6" => chr(22),
128 - "\x1B!7" => chr(23),
129 - "\x1B!8" => chr(24),
130 - "\x1B!9" => chr(25),
131 - "\x1B!:" => chr(26),
132 - "\x1B!;" => chr(27),
133 - "\x1B!<" => chr(28),
134 - "\x1B!=" => chr(29),
135 - "\x1B!>" => chr(30),
136 - "\x1B!?" => chr(31),
137 - "\x1B'?" => chr(127),
138 - "\x1B(0" => '€', // 128 in CP1252
139 - "\x1B(2" => '‚', // 130 in CP1252
140 - "\x1B(3" => 'ƒ', // 131 in CP1252
141 - "\x1B(4" => '„', // 132 in CP1252
142 - "\x1B(5" => '…', // 133 in CP1252
143 - "\x1B(6" => '†', // 134 in CP1252
144 - "\x1B(7" => '‡', // 135 in CP1252
145 - "\x1B(8" => 'ˆ', // 136 in CP1252
146 - "\x1B(9" => '‰', // 137 in CP1252
147 - "\x1B(:" => 'Š', // 138 in CP1252
148 - "\x1B(;" => '‹', // 139 in CP1252
149 - "\x1BNj" => 'Œ', // 140 in CP1252
150 - "\x1B(>" => 'Ž', // 142 in CP1252
151 - "\x1B)1" => '‘', // 145 in CP1252
152 - "\x1B)2" => '’', // 146 in CP1252
153 - "\x1B)3" => '“', // 147 in CP1252
154 - "\x1B)4" => '”', // 148 in CP1252
155 - "\x1B)5" => '•', // 149 in CP1252
156 - "\x1B)6" => '–', // 150 in CP1252
157 - "\x1B)7" => '—', // 151 in CP1252
158 - "\x1B)8" => '˜', // 152 in CP1252
159 - "\x1B)9" => '™', // 153 in CP1252
160 - "\x1B):" => 'š', // 154 in CP1252
161 - "\x1B);" => '›', // 155 in CP1252
162 - "\x1BNz" => 'œ', // 156 in CP1252
163 - "\x1B)>" => 'ž', // 158 in CP1252
164 - "\x1B)?" => 'Ÿ', // 159 in CP1252
165 - "\x1B*0" => ' ', // 160 in CP1252
166 - "\x1BN!" => '¡', // 161 in CP1252
167 - "\x1BN\"" => '¢', // 162 in CP1252
168 - "\x1BN#" => '£', // 163 in CP1252
169 - "\x1BN(" => '¤', // 164 in CP1252
170 - "\x1BN%" => '¥', // 165 in CP1252
171 - "\x1B*6" => '¦', // 166 in CP1252
172 - "\x1BN'" => '§', // 167 in CP1252
173 - "\x1BNH " => '¨', // 168 in CP1252
174 - "\x1BNS" => '©', // 169 in CP1252
175 - "\x1BNc" => 'ª', // 170 in CP1252
176 - "\x1BN+" => '«', // 171 in CP1252
177 - "\x1B*<" => '¬', // 172 in CP1252
178 - "\x1B*=" => '­', // 173 in CP1252
179 - "\x1BNR" => '®', // 174 in CP1252
180 - "\x1B*?" => '¯', // 175 in CP1252
181 - "\x1BN0" => '°', // 176 in CP1252
182 - "\x1BN1" => '±', // 177 in CP1252
183 - "\x1BN2" => '²', // 178 in CP1252
184 - "\x1BN3" => '³', // 179 in CP1252
185 - "\x1BNB " => '´', // 180 in CP1252
186 - "\x1BN5" => 'µ', // 181 in CP1252
187 - "\x1BN6" => '¶', // 182 in CP1252
188 - "\x1BN7" => '·', // 183 in CP1252
189 - "\x1B+8" => '¸', // 184 in CP1252
190 - "\x1BNQ" => '¹', // 185 in CP1252
191 - "\x1BNk" => 'º', // 186 in CP1252
192 - "\x1BN;" => '»', // 187 in CP1252
193 - "\x1BN<" => '¼', // 188 in CP1252
194 - "\x1BN=" => '½', // 189 in CP1252
195 - "\x1BN>" => '¾', // 190 in CP1252
196 - "\x1BN?" => '¿', // 191 in CP1252
197 - "\x1BNAA" => 'À', // 192 in CP1252
198 - "\x1BNBA" => 'Á', // 193 in CP1252
199 - "\x1BNCA" => 'Â', // 194 in CP1252
200 - "\x1BNDA" => 'Ã', // 195 in CP1252
201 - "\x1BNHA" => 'Ä', // 196 in CP1252
202 - "\x1BNJA" => 'Å', // 197 in CP1252
203 - "\x1BNa" => 'Æ', // 198 in CP1252
204 - "\x1BNKC" => 'Ç', // 199 in CP1252
205 - "\x1BNAE" => 'È', // 200 in CP1252
206 - "\x1BNBE" => 'É', // 201 in CP1252
207 - "\x1BNCE" => 'Ê', // 202 in CP1252
208 - "\x1BNHE" => 'Ë', // 203 in CP1252
209 - "\x1BNAI" => 'Ì', // 204 in CP1252
210 - "\x1BNBI" => 'Í', // 205 in CP1252
211 - "\x1BNCI" => 'Î', // 206 in CP1252
212 - "\x1BNHI" => 'Ï', // 207 in CP1252
213 - "\x1BNb" => 'Ð', // 208 in CP1252
214 - "\x1BNDN" => 'Ñ', // 209 in CP1252
215 - "\x1BNAO" => 'Ò', // 210 in CP1252
216 - "\x1BNBO" => 'Ó', // 211 in CP1252
217 - "\x1BNCO" => 'Ô', // 212 in CP1252
218 - "\x1BNDO" => 'Õ', // 213 in CP1252
219 - "\x1BNHO" => 'Ö', // 214 in CP1252
220 - "\x1B-7" => '×', // 215 in CP1252
221 - "\x1BNi" => 'Ø', // 216 in CP1252
222 - "\x1BNAU" => 'Ù', // 217 in CP1252
223 - "\x1BNBU" => 'Ú', // 218 in CP1252
224 - "\x1BNCU" => 'Û', // 219 in CP1252
225 - "\x1BNHU" => 'Ü', // 220 in CP1252
226 - "\x1B-=" => 'Ý', // 221 in CP1252
227 - "\x1BNl" => 'Þ', // 222 in CP1252
228 - "\x1BN{" => 'ß', // 223 in CP1252
229 - "\x1BNAa" => 'à', // 224 in CP1252
230 - "\x1BNBa" => 'á', // 225 in CP1252
231 - "\x1BNCa" => 'â', // 226 in CP1252
232 - "\x1BNDa" => 'ã', // 227 in CP1252
233 - "\x1BNHa" => 'ä', // 228 in CP1252
234 - "\x1BNJa" => 'å', // 229 in CP1252
235 - "\x1BNq" => 'æ', // 230 in CP1252
236 - "\x1BNKc" => 'ç', // 231 in CP1252
237 - "\x1BNAe" => 'è', // 232 in CP1252
238 - "\x1BNBe" => 'é', // 233 in CP1252
239 - "\x1BNCe" => 'ê', // 234 in CP1252
240 - "\x1BNHe" => 'ë', // 235 in CP1252
241 - "\x1BNAi" => 'ì', // 236 in CP1252
242 - "\x1BNBi" => 'í', // 237 in CP1252
243 - "\x1BNCi" => 'î', // 238 in CP1252
244 - "\x1BNHi" => 'ï', // 239 in CP1252
245 - "\x1BNs" => 'ð', // 240 in CP1252
246 - "\x1BNDn" => 'ñ', // 241 in CP1252
247 - "\x1BNAo" => 'ò', // 242 in CP1252
248 - "\x1BNBo" => 'ó', // 243 in CP1252
249 - "\x1BNCo" => 'ô', // 244 in CP1252
250 - "\x1BNDo" => 'õ', // 245 in CP1252
251 - "\x1BNHo" => 'ö', // 246 in CP1252
252 - "\x1B/7" => '÷', // 247 in CP1252
253 - "\x1BNy" => 'ø', // 248 in CP1252
254 - "\x1BNAu" => 'ù', // 249 in CP1252
255 - "\x1BNBu" => 'ú', // 250 in CP1252
256 - "\x1BNCu" => 'û', // 251 in CP1252
257 - "\x1BNHu" => 'ü', // 252 in CP1252
258 - "\x1B/=" => 'ý', // 253 in CP1252
259 - "\x1BN|" => 'þ', // 254 in CP1252
260 - "\x1BNHy" => 'ÿ', // 255 in CP1252
261 - );
262 - }
106 + /**
107 + * Build SYLK characters array
108 + */
109 + private static function _buildSYLKCharacters()
110 + {
111 + self::$_SYLKCharacters = array(
112 + "\x1B 0" => chr(0),
113 + "\x1B 1" => chr(1),
114 + "\x1B 2" => chr(2),
115 + "\x1B 3" => chr(3),
116 + "\x1B 4" => chr(4),
117 + "\x1B 5" => chr(5),
118 + "\x1B 6" => chr(6),
119 + "\x1B 7" => chr(7),
120 + "\x1B 8" => chr(8),
121 + "\x1B 9" => chr(9),
122 + "\x1B :" => chr(10),
123 + "\x1B ;" => chr(11),
124 + "\x1B <" => chr(12),
125 + "\x1B :" => chr(13),
126 + "\x1B >" => chr(14),
127 + "\x1B ?" => chr(15),
128 + "\x1B!0" => chr(16),
129 + "\x1B!1" => chr(17),
130 + "\x1B!2" => chr(18),
131 + "\x1B!3" => chr(19),
132 + "\x1B!4" => chr(20),
133 + "\x1B!5" => chr(21),
134 + "\x1B!6" => chr(22),
135 + "\x1B!7" => chr(23),
136 + "\x1B!8" => chr(24),
137 + "\x1B!9" => chr(25),
138 + "\x1B!:" => chr(26),
139 + "\x1B!;" => chr(27),
140 + "\x1B!<" => chr(28),
141 + "\x1B!=" => chr(29),
142 + "\x1B!>" => chr(30),
143 + "\x1B!?" => chr(31),
144 + "\x1B'?" => chr(127),
145 + "\x1B(0" => '€', // 128 in CP1252
146 + "\x1B(2" => '‚', // 130 in CP1252
147 + "\x1B(3" => 'ƒ', // 131 in CP1252
148 + "\x1B(4" => '„', // 132 in CP1252
149 + "\x1B(5" => '…', // 133 in CP1252
150 + "\x1B(6" => '†', // 134 in CP1252
151 + "\x1B(7" => '‡', // 135 in CP1252
152 + "\x1B(8" => 'ˆ', // 136 in CP1252
153 + "\x1B(9" => '‰', // 137 in CP1252
154 + "\x1B(:" => 'Š', // 138 in CP1252
155 + "\x1B(;" => '‹', // 139 in CP1252
156 + "\x1BNj" => 'Œ', // 140 in CP1252
157 + "\x1B(>" => 'Ž', // 142 in CP1252
158 + "\x1B)1" => '‘', // 145 in CP1252
159 + "\x1B)2" => '’', // 146 in CP1252
160 + "\x1B)3" => '“', // 147 in CP1252
161 + "\x1B)4" => '”', // 148 in CP1252
162 + "\x1B)5" => '•', // 149 in CP1252
163 + "\x1B)6" => '–', // 150 in CP1252
164 + "\x1B)7" => '—', // 151 in CP1252
165 + "\x1B)8" => '˜', // 152 in CP1252
166 + "\x1B)9" => '™', // 153 in CP1252
167 + "\x1B):" => 'š', // 154 in CP1252
168 + "\x1B);" => '›', // 155 in CP1252
169 + "\x1BNz" => 'œ', // 156 in CP1252
170 + "\x1B)>" => 'ž', // 158 in CP1252
171 + "\x1B)?" => 'Ÿ', // 159 in CP1252
172 + "\x1B*0" => ' ', // 160 in CP1252
173 + "\x1BN!" => '¡', // 161 in CP1252
174 + "\x1BN\"" => '¢', // 162 in CP1252
175 + "\x1BN#" => '£', // 163 in CP1252
176 + "\x1BN(" => '¤', // 164 in CP1252
177 + "\x1BN%" => '¥', // 165 in CP1252
178 + "\x1B*6" => '¦', // 166 in CP1252
179 + "\x1BN'" => '§', // 167 in CP1252
180 + "\x1BNH " => '¨', // 168 in CP1252
181 + "\x1BNS" => '©', // 169 in CP1252
182 + "\x1BNc" => 'ª', // 170 in CP1252
183 + "\x1BN+" => '«', // 171 in CP1252
184 + "\x1B*<" => '¬', // 172 in CP1252
185 + "\x1B*=" => '­', // 173 in CP1252
186 + "\x1BNR" => '®', // 174 in CP1252
187 + "\x1B*?" => '¯', // 175 in CP1252
188 + "\x1BN0" => '°', // 176 in CP1252
189 + "\x1BN1" => '±', // 177 in CP1252
190 + "\x1BN2" => '²', // 178 in CP1252
191 + "\x1BN3" => '³', // 179 in CP1252
192 + "\x1BNB " => '´', // 180 in CP1252
193 + "\x1BN5" => 'µ', // 181 in CP1252
194 + "\x1BN6" => '¶', // 182 in CP1252
195 + "\x1BN7" => '·', // 183 in CP1252
196 + "\x1B+8" => '¸', // 184 in CP1252
197 + "\x1BNQ" => '¹', // 185 in CP1252
198 + "\x1BNk" => 'º', // 186 in CP1252
199 + "\x1BN;" => '»', // 187 in CP1252
200 + "\x1BN<" => '¼', // 188 in CP1252
201 + "\x1BN=" => '½', // 189 in CP1252
202 + "\x1BN>" => '¾', // 190 in CP1252
203 + "\x1BN?" => '¿', // 191 in CP1252
204 + "\x1BNAA" => 'À', // 192 in CP1252
205 + "\x1BNBA" => 'Á', // 193 in CP1252
206 + "\x1BNCA" => 'Â', // 194 in CP1252
207 + "\x1BNDA" => 'Ã', // 195 in CP1252
208 + "\x1BNHA" => 'Ä', // 196 in CP1252
209 + "\x1BNJA" => 'Å', // 197 in CP1252
210 + "\x1BNa" => 'Æ', // 198 in CP1252
211 + "\x1BNKC" => 'Ç', // 199 in CP1252
212 + "\x1BNAE" => 'È', // 200 in CP1252
213 + "\x1BNBE" => 'É', // 201 in CP1252
214 + "\x1BNCE" => 'Ê', // 202 in CP1252
215 + "\x1BNHE" => 'Ë', // 203 in CP1252
216 + "\x1BNAI" => 'Ì', // 204 in CP1252
217 + "\x1BNBI" => 'Í', // 205 in CP1252
218 + "\x1BNCI" => 'Î', // 206 in CP1252
219 + "\x1BNHI" => 'Ï', // 207 in CP1252
220 + "\x1BNb" => 'Ð', // 208 in CP1252
221 + "\x1BNDN" => 'Ñ', // 209 in CP1252
222 + "\x1BNAO" => 'Ò', // 210 in CP1252
223 + "\x1BNBO" => 'Ó', // 211 in CP1252
224 + "\x1BNCO" => 'Ô', // 212 in CP1252
225 + "\x1BNDO" => 'Õ', // 213 in CP1252
226 + "\x1BNHO" => 'Ö', // 214 in CP1252
227 + "\x1B-7" => '×', // 215 in CP1252
228 + "\x1BNi" => 'Ø', // 216 in CP1252
229 + "\x1BNAU" => 'Ù', // 217 in CP1252
230 + "\x1BNBU" => 'Ú', // 218 in CP1252
231 + "\x1BNCU" => 'Û', // 219 in CP1252
232 + "\x1BNHU" => 'Ü', // 220 in CP1252
233 + "\x1B-=" => 'Ý', // 221 in CP1252
234 + "\x1BNl" => 'Þ', // 222 in CP1252
235 + "\x1BN{" => 'ß', // 223 in CP1252
236 + "\x1BNAa" => 'à', // 224 in CP1252
237 + "\x1BNBa" => 'á', // 225 in CP1252
238 + "\x1BNCa" => 'â', // 226 in CP1252
239 + "\x1BNDa" => 'ã', // 227 in CP1252
240 + "\x1BNHa" => 'ä', // 228 in CP1252
241 + "\x1BNJa" => 'å', // 229 in CP1252
242 + "\x1BNq" => 'æ', // 230 in CP1252
243 + "\x1BNKc" => 'ç', // 231 in CP1252
244 + "\x1BNAe" => 'è', // 232 in CP1252
245 + "\x1BNBe" => 'é', // 233 in CP1252
246 + "\x1BNCe" => 'ê', // 234 in CP1252
247 + "\x1BNHe" => 'ë', // 235 in CP1252
248 + "\x1BNAi" => 'ì', // 236 in CP1252
249 + "\x1BNBi" => 'í', // 237 in CP1252
250 + "\x1BNCi" => 'î', // 238 in CP1252
251 + "\x1BNHi" => 'ï', // 239 in CP1252
252 + "\x1BNs" => 'ð', // 240 in CP1252
253 + "\x1BNDn" => 'ñ', // 241 in CP1252
254 + "\x1BNAo" => 'ò', // 242 in CP1252
255 + "\x1BNBo" => 'ó', // 243 in CP1252
256 + "\x1BNCo" => 'ô', // 244 in CP1252
257 + "\x1BNDo" => 'õ', // 245 in CP1252
258 + "\x1BNHo" => 'ö', // 246 in CP1252
259 + "\x1B/7" => '÷', // 247 in CP1252
260 + "\x1BNy" => 'ø', // 248 in CP1252
261 + "\x1BNAu" => 'ù', // 249 in CP1252
262 + "\x1BNBu" => 'ú', // 250 in CP1252
263 + "\x1BNCu" => 'û', // 251 in CP1252
264 + "\x1BNHu" => 'ü', // 252 in CP1252
265 + "\x1B/=" => 'ý', // 253 in CP1252
266 + "\x1BN|" => 'þ', // 254 in CP1252
267 + "\x1BNHy" => 'ÿ', // 255 in CP1252
268 + );
269 + }
263 270
264 - /**
265 - * Get whether mbstring extension is available
266 - *
267 - * @return boolean
268 - */
269 - public static function getIsMbstringEnabled()
270 - {
271 - if (isset(self::$isMbstringEnabled)) {
272 - return self::$isMbstringEnabled;
273 - }
271 + /**
272 + * Get whether mbstring extension is available
273 + *
274 + * @return boolean
275 + */
276 + public static function getIsMbstringEnabled()
277 + {
278 + if (isset(self::$_isMbstringEnabled)) {
279 + return self::$_isMbstringEnabled;
280 + }
274 281
275 - self::$isMbstringEnabled = function_exists('mb_convert_encoding') ?
276 - true : false;
282 + self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
283 + true : false;
277 284
278 - return self::$isMbstringEnabled;
279 - }
285 + return self::$_isMbstringEnabled;
286 + }
280 287
281 - /**
282 - * Get whether iconv extension is available
283 - *
284 - * @return boolean
285 - */
286 - public static function getIsIconvEnabled()
287 - {
288 - if (isset(self::$isIconvEnabled)) {
289 - return self::$isIconvEnabled;
290 - }
288 + /**
289 + * Get whether iconv extension is available
290 + *
291 + * @return boolean
292 + */
293 + public static function getIsIconvEnabled()
294 + {
295 + if (isset(self::$_isIconvEnabled)) {
296 + return self::$_isIconvEnabled;
297 + }
291 298
292 - // Fail if iconv doesn't exist
293 - if (!function_exists('iconv')) {
294 - self::$isIconvEnabled = false;
295 - return false;
296 - }
299 + // Fail if iconv doesn't exist
300 + if (!function_exists('iconv')) {
301 + self::$_isIconvEnabled = false;
302 + return false;
303 + }
297 304
298 - // Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
299 - if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
300 - self::$isIconvEnabled = false;
301 - return false;
302 - }
305 + // Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
306 + if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
307 + self::$_isIconvEnabled = false;
308 + return false;
309 + }
303 310
304 - // Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
305 - // we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
306 - if (!@iconv_substr('A', 0, 1, 'UTF-8')) {
307 - self::$isIconvEnabled = false;
308 - return false;
309 - }
311 + // Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
312 + // we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
313 + if (!@iconv_substr('A', 0, 1, 'UTF-8')) {
314 + self::$_isIconvEnabled = false;
315 + return false;
316 + }
310 317
311 - // CUSTOM: IBM AIX iconv() does not work
312 - if (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
313 - self::$isIconvEnabled = false;
314 - return false;
315 - }
318 + // CUSTOM: IBM AIX iconv() does not work
319 + if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX')
320 + && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
321 + && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
322 + {
323 + self::$_isIconvEnabled = false;
324 + return false;
325 + }
316 326
317 - // If we reach here no problems were detected with iconv
318 - self::$isIconvEnabled = true;
319 - return true;
320 - }
327 + // If we reach here no problems were detected with iconv
328 + self::$_isIconvEnabled = true;
329 + return true;
330 + }
321 331
322 - public static function buildCharacterSets()
323 - {
324 - if (empty(self::$controlCharacters)) {
325 - self::buildControlCharacters();
326 - }
327 - if (empty(self::$SYLKCharacters)) {
328 - self::buildSYLKCharacters();
329 - }
330 - }
332 + public static function buildCharacterSets() {
333 + if(empty(self::$_controlCharacters)) {
334 + self::_buildControlCharacters();
335 + }
336 + if(empty(self::$_SYLKCharacters)) {
337 + self::_buildSYLKCharacters();
338 + }
339 + }
331 340
332 - /**
333 - * Convert from OpenXML escaped control character to PHP control character
334 - *
335 - * Excel 2007 team:
336 - * ----------------
337 - * That's correct, control characters are stored directly in the shared-strings table.
338 - * We do encode characters that cannot be represented in XML using the following escape sequence:
339 - * _xHHHH_ where H represents a hexadecimal character in the character's value...
340 - * So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
341 - * element or in the shared string <t> element.
342 - *
343 - * @param string $value Value to unescape
344 - * @return string
345 - */
346 - public static function ControlCharacterOOXML2PHP($value = '')
347 - {
348 - return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value);
349 - }
341 + /**
342 + * Convert from OpenXML escaped control character to PHP control character
343 + *
344 + * Excel 2007 team:
345 + * ----------------
346 + * That's correct, control characters are stored directly in the shared-strings table.
347 + * We do encode characters that cannot be represented in XML using the following escape sequence:
348 + * _xHHHH_ where H represents a hexadecimal character in the character's value...
349 + * So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
350 + * element or in the shared string <t> element.
351 + *
352 + * @param string $value Value to unescape
353 + * @return string
354 + */
355 + public static function ControlCharacterOOXML2PHP($value = '') {
356 + return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
357 + }
350 358
351 - /**
352 - * Convert from PHP control character to OpenXML escaped control character
353 - *
354 - * Excel 2007 team:
355 - * ----------------
356 - * That's correct, control characters are stored directly in the shared-strings table.
357 - * We do encode characters that cannot be represented in XML using the following escape sequence:
358 - * _xHHHH_ where H represents a hexadecimal character in the character's value...
359 - * So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
360 - * element or in the shared string <t> element.
361 - *
362 - * @param string $value Value to escape
363 - * @return string
364 - */
365 - public static function ControlCharacterPHP2OOXML($value = '')
366 - {
367 - return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value);
368 - }
359 + /**
360 + * Convert from PHP control character to OpenXML escaped control character
361 + *
362 + * Excel 2007 team:
363 + * ----------------
364 + * That's correct, control characters are stored directly in the shared-strings table.
365 + * We do encode characters that cannot be represented in XML using the following escape sequence:
366 + * _xHHHH_ where H represents a hexadecimal character in the character's value...
367 + * So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
368 + * element or in the shared string <t> element.
369 + *
370 + * @param string $value Value to escape
371 + * @return string
372 + */
373 + public static function ControlCharacterPHP2OOXML($value = '') {
374 + return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
375 + }
369 376
370 - /**
371 - * Try to sanitize UTF8, stripping invalid byte sequences. Not perfect. Does not surrogate characters.
372 - *
373 - * @param string $value
374 - * @return string
375 - */
376 - public static function SanitizeUTF8($value)
377 - {
378 - if (self::getIsIconvEnabled()) {
379 - $value = @iconv('UTF-8', 'UTF-8', $value);
380 - return $value;
381 - }
377 + /**
378 + * Try to sanitize UTF8, stripping invalid byte sequences. Not perfect. Does not surrogate characters.
379 + *
380 + * @param string $value
381 + * @return string
382 + */
383 + public static function SanitizeUTF8($value)
384 + {
385 + if (self::getIsIconvEnabled()) {
386 + $value = @iconv('UTF-8', 'UTF-8', $value);
387 + return $value;
388 + }
382 389
383 - if (self::getIsMbstringEnabled()) {
384 - $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
385 - return $value;
386 - }
390 + if (self::getIsMbstringEnabled()) {
391 + $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
392 + return $value;
393 + }
387 394
388 - // else, no conversion
389 - return $value;
390 - }
395 + // else, no conversion
396 + return $value;
397 + }
391 398
392 - /**
393 - * Check if a string contains UTF8 data
394 - *
395 - * @param string $value
396 - * @return boolean
397 - */
398 - public static function IsUTF8($value = '')
399 - {
400 - return $value === '' || preg_match('/^./su', $value) === 1;
401 - }
399 + /**
400 + * Check if a string contains UTF8 data
401 + *
402 + * @param string $value
403 + * @return boolean
404 + */
405 + public static function IsUTF8($value = '') {
406 + return $value === '' || preg_match('/^./su', $value) === 1;
407 + }
402 408
403 - /**
404 - * Formats a numeric value as a string for output in various output writers forcing
405 - * point as decimal separator in case locale is other than English.
406 - *
407 - * @param mixed $value
408 - * @return string
409 - */
410 - public static function FormatNumber($value)
411 - {
412 - if (is_float($value)) {
413 - return str_replace(',', '.', $value);
414 - }
415 - return (string) $value;
416 - }
409 + /**
410 + * Formats a numeric value as a string for output in various output writers forcing
411 + * point as decimal separator in case locale is other than English.
412 + *
413 + * @param mixed $value
414 + * @return string
415 + */
416 + public static function FormatNumber($value) {
417 + if (is_float($value)) {
418 + return str_replace(',', '.', $value);
419 + }
420 + return (string) $value;
421 + }
417 422
418 - /**
419 - * Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
420 - * Writes the string using uncompressed notation, no rich text, no Asian phonetics
421 - * If mbstring extension is not available, ASCII is assumed, and compressed notation is used
422 - * although this will give wrong results for non-ASCII strings
423 - * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
424 - *
425 - * @param string $value UTF-8 encoded string
426 - * @param mixed[] $arrcRuns Details of rich text runs in $value
427 - * @return string
428 - */
429 - public static function UTF8toBIFF8UnicodeShort($value, $arrcRuns = array())
430 - {
431 - // character count
432 - $ln = self::CountCharacters($value, 'UTF-8');
433 - // option flags
434 - if (empty($arrcRuns)) {
435 - $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
436 - 0x0001 : 0x0000;
437 - $data = pack('CC', $ln, $opt);
438 - // characters
439 - $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
440 - } else {
441 - $data = pack('vC', $ln, 0x09);
442 - $data .= pack('v', count($arrcRuns));
443 - // characters
444 - $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
445 - foreach ($arrcRuns as $cRun) {
446 - $data .= pack('v', $cRun['strlen']);
447 - $data .= pack('v', $cRun['fontidx']);
448 - }
449 - }
450 - return $data;
451 - }
423 + /**
424 + * Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
425 + * Writes the string using uncompressed notation, no rich text, no Asian phonetics
426 + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used
427 + * although this will give wrong results for non-ASCII strings
428 + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
429 + *
430 + * @param string $value UTF-8 encoded string
431 + * @param mixed[] $arrcRuns Details of rich text runs in $value
432 + * @return string
433 + */
434 + public static function UTF8toBIFF8UnicodeShort($value, $arrcRuns = array())
435 + {
436 + // character count
437 + $ln = self::CountCharacters($value, 'UTF-8');
438 + // option flags
439 + if(empty($arrcRuns)){
440 + $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
441 + 0x0001 : 0x0000;
442 + $data = pack('CC', $ln, $opt);
443 + // characters
444 + $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
445 + }
446 + else {
447 + $data = pack('vC', $ln, 0x09);
448 + $data .= pack('v', count($arrcRuns));
449 + // characters
450 + $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
451 + foreach ($arrcRuns as $cRun){
452 + $data .= pack('v', $cRun['strlen']);
453 + $data .= pack('v', $cRun['fontidx']);
454 + }
455 + }
456 + return $data;
457 + }
452 458
453 - /**
454 - * Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length)
455 - * Writes the string using uncompressed notation, no rich text, no Asian phonetics
456 - * If mbstring extension is not available, ASCII is assumed, and compressed notation is used
457 - * although this will give wrong results for non-ASCII strings
458 - * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
459 - *
460 - * @param string $value UTF-8 encoded string
461 - * @return string
462 - */
463 - public static function UTF8toBIFF8UnicodeLong($value)
464 - {
465 - // character count
466 - $ln = self::CountCharacters($value, 'UTF-8');
459 + /**
460 + * Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length)
461 + * Writes the string using uncompressed notation, no rich text, no Asian phonetics
462 + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used
463 + * although this will give wrong results for non-ASCII strings
464 + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
465 + *
466 + * @param string $value UTF-8 encoded string
467 + * @return string
468 + */
469 + public static function UTF8toBIFF8UnicodeLong($value)
470 + {
471 + // character count
472 + $ln = self::CountCharacters($value, 'UTF-8');
467 473
468 - // option flags
469 - $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
470 - 0x0001 : 0x0000;
474 + // option flags
475 + $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
476 + 0x0001 : 0x0000;
471 477
472 - // characters
473 - $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
478 + // characters
479 + $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
474 480
475 - $data = pack('vC', $ln, $opt) . $chars;
476 - return $data;
477 - }
481 + $data = pack('vC', $ln, $opt) . $chars;
482 + return $data;
483 + }
478 484
479 - /**
480 - * Convert string from one encoding to another. First try mbstring, then iconv, finally strlen
481 - *
482 - * @param string $value
483 - * @param string $to Encoding to convert to, e.g. 'UTF-8'
484 - * @param string $from Encoding to convert from, e.g. 'UTF-16LE'
485 - * @return string
486 - */
487 - public static function ConvertEncoding($value, $to, $from)
488 - {
489 - if (self::getIsIconvEnabled()) {
490 - return iconv($from, $to, $value);
491 - }
485 + /**
486 + * Convert string from one encoding to another. First try mbstring, then iconv, finally strlen
487 + *
488 + * @param string $value
489 + * @param string $to Encoding to convert to, e.g. 'UTF-8'
490 + * @param string $from Encoding to convert from, e.g. 'UTF-16LE'
491 + * @return string
492 + */
493 + public static function ConvertEncoding($value, $to, $from)
494 + {
495 + if (self::getIsIconvEnabled()) {
496 + return iconv($from, $to, $value);
497 + }
492 498
493 - if (self::getIsMbstringEnabled()) {
494 - return mb_convert_encoding($value, $to, $from);
495 - }
499 + if (self::getIsMbstringEnabled()) {
500 + return mb_convert_encoding($value, $to, $from);
501 + }
496 502
497 - if ($from == 'UTF-16LE') {
498 - return self::utf16_decode($value, false);
499 - } elseif ($from == 'UTF-16BE') {
500 - return self::utf16_decode($value);
501 - }
502 - // else, no conversion
503 - return $value;
504 - }
503 + if($from == 'UTF-16LE'){
504 + return self::utf16_decode($value, false);
505 + }else if($from == 'UTF-16BE'){
506 + return self::utf16_decode($value);
507 + }
508 + // else, no conversion
509 + return $value;
510 + }
505 511
506 - /**
507 - * Decode UTF-16 encoded strings.
508 - *
509 - * Can handle both BOM'ed data and un-BOM'ed data.
510 - * Assumes Big-Endian byte order if no BOM is available.
511 - * This function was taken from http://php.net/manual/en/function.utf8-decode.php
512 - * and $bom_be parameter added.
513 - *
514 - * @param string $str UTF-16 encoded data to decode.
515 - * @return string UTF-8 / ISO encoded data.
516 - * @access public
517 - * @version 0.2 / 2010-05-13
518 - * @author Rasmus Andersson {@link http://rasmusandersson.se/}
519 - * @author vadik56
520 - */
521 - public static function utf16_decode($str, $bom_be = true)
522 - {
523 - if (strlen($str) < 2) {
524 - return $str;
525 - }
526 - $c0 = ord($str{0});
527 - $c1 = ord($str{1});
528 - if ($c0 == 0xfe && $c1 == 0xff) {
529 - $str = substr($str, 2);
530 - } elseif ($c0 == 0xff && $c1 == 0xfe) {
531 - $str = substr($str, 2);
532 - $bom_be = false;
533 - }
534 - $len = strlen($str);
535 - $newstr = '';
536 - for ($i=0; $i<$len; $i+=2) {
537 - if ($bom_be) {
538 - $val = ord($str{$i}) << 4;
539 - $val += ord($str{$i+1});
540 - } else {
541 - $val = ord($str{$i+1}) << 4;
542 - $val += ord($str{$i});
543 - }
544 - $newstr .= ($val == 0x228) ? "\n" : chr($val);
545 - }
546 - return $newstr;
547 - }
512 + /**
513 + * Decode UTF-16 encoded strings.
514 + *
515 + * Can handle both BOM'ed data and un-BOM'ed data.
516 + * Assumes Big-Endian byte order if no BOM is available.
517 + * This function was taken from http://php.net/manual/en/function.utf8-decode.php
518 + * and $bom_be parameter added.
519 + *
520 + * @param string $str UTF-16 encoded data to decode.
521 + * @return string UTF-8 / ISO encoded data.
522 + * @access public
523 + * @version 0.2 / 2010-05-13
524 + * @author Rasmus Andersson {@link http://rasmusandersson.se/}
525 + * @author vadik56
526 + */
527 + public static function utf16_decode($str, $bom_be = TRUE) {
528 + if( strlen($str) < 2 ) return $str;
529 + $c0 = ord($str{0});
530 + $c1 = ord($str{1});
531 + if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
532 + elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
533 + $len = strlen($str);
534 + $newstr = '';
535 + for($i=0;$i<$len;$i+=2) {
536 + if( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
537 + else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
538 + $newstr .= ($val == 0x228) ? "\n" : chr($val);
539 + }
540 + return $newstr;
541 + }
548 542
549 - /**
550 - * Get character count. First try mbstring, then iconv, finally strlen
551 - *
552 - * @param string $value
553 - * @param string $enc Encoding
554 - * @return int Character count
555 - */
556 - public static function CountCharacters($value, $enc = 'UTF-8')
557 - {
558 - if (self::getIsMbstringEnabled()) {
559 - return mb_strlen($value, $enc);
560 - }
543 + /**
544 + * Get character count. First try mbstring, then iconv, finally strlen
545 + *
546 + * @param string $value
547 + * @param string $enc Encoding
548 + * @return int Character count
549 + */
550 + public static function CountCharacters($value, $enc = 'UTF-8')
551 + {
552 + if (self::getIsMbstringEnabled()) {
553 + return mb_strlen($value, $enc);
554 + }
561 555
562 - if (self::getIsIconvEnabled()) {
563 - return iconv_strlen($value, $enc);
564 - }
556 + if (self::getIsIconvEnabled()) {
557 + return iconv_strlen($value, $enc);
558 + }
565 559
566 - // else strlen
567 - return strlen($value);
568 - }
560 + // else strlen
561 + return strlen($value);
562 + }
569 563
570 - /**
571 - * Get a substring of a UTF-8 encoded string. First try mbstring, then iconv, finally strlen
572 - *
573 - * @param string $pValue UTF-8 encoded string
574 - * @param int $pStart Start offset
575 - * @param int $pLength Maximum number of characters in substring
576 - * @return string
577 - */
578 - public static function Substring($pValue = '', $pStart = 0, $pLength = 0)
579 - {
580 - if (self::getIsMbstringEnabled()) {
581 - return mb_substr($pValue, $pStart, $pLength, 'UTF-8');
582 - }
564 + /**
565 + * Get a substring of a UTF-8 encoded string. First try mbstring, then iconv, finally strlen
566 + *
567 + * @param string $pValue UTF-8 encoded string
568 + * @param int $pStart Start offset
569 + * @param int $pLength Maximum number of characters in substring
570 + * @return string
571 + */
572 + public static function Substring($pValue = '', $pStart = 0, $pLength = 0)
573 + {
574 + if (self::getIsMbstringEnabled()) {
575 + return mb_substr($pValue, $pStart, $pLength, 'UTF-8');
576 + }
583 577
584 - if (self::getIsIconvEnabled()) {
585 - return iconv_substr($pValue, $pStart, $pLength, 'UTF-8');
586 - }
578 + if (self::getIsIconvEnabled()) {
579 + return iconv_substr($pValue, $pStart, $pLength, 'UTF-8');
580 + }
587 581
588 - // else substr
589 - return substr($pValue, $pStart, $pLength);
590 - }
582 + // else substr
583 + return substr($pValue, $pStart, $pLength);
584 + }
591 585
592 - /**
593 - * Convert a UTF-8 encoded string to upper case
594 - *
595 - * @param string $pValue UTF-8 encoded string
596 - * @return string
597 - */
598 - public static function StrToUpper($pValue = '')
599 - {
600 - if (function_exists('mb_convert_case')) {
601 - return mb_convert_case($pValue, MB_CASE_UPPER, "UTF-8");
602 - }
603 - return strtoupper($pValue);
604 - }
586 + /**
587 + * Convert a UTF-8 encoded string to upper case
588 + *
589 + * @param string $pValue UTF-8 encoded string
590 + * @return string
591 + */
592 + public static function StrToUpper($pValue = '')
593 + {
594 + if (function_exists('mb_convert_case')) {
595 + return mb_convert_case($pValue, MB_CASE_UPPER, "UTF-8");
596 + }
597 + return strtoupper($pValue);
598 + }
605 599
606 - /**
607 - * Convert a UTF-8 encoded string to lower case
608 - *
609 - * @param string $pValue UTF-8 encoded string
610 - * @return string
611 - */
612 - public static function StrToLower($pValue = '')
613 - {
614 - if (function_exists('mb_convert_case')) {
615 - return mb_convert_case($pValue, MB_CASE_LOWER, "UTF-8");
616 - }
617 - return strtolower($pValue);
618 - }
600 + /**
601 + * Convert a UTF-8 encoded string to lower case
602 + *
603 + * @param string $pValue UTF-8 encoded string
604 + * @return string
605 + */
606 + public static function StrToLower($pValue = '')
607 + {
608 + if (function_exists('mb_convert_case')) {
609 + return mb_convert_case($pValue, MB_CASE_LOWER, "UTF-8");
610 + }
611 + return strtolower($pValue);
612 + }
619 613
620 - /**
621 - * Convert a UTF-8 encoded string to title/proper case
622 - * (uppercase every first character in each word, lower case all other characters)
623 - *
624 - * @param string $pValue UTF-8 encoded string
625 - * @return string
626 - */
627 - public static function StrToTitle($pValue = '')
628 - {
629 - if (function_exists('mb_convert_case')) {
630 - return mb_convert_case($pValue, MB_CASE_TITLE, "UTF-8");
631 - }
632 - return ucwords($pValue);
633 - }
614 + /**
615 + * Convert a UTF-8 encoded string to title/proper case
616 + * (uppercase every first character in each word, lower case all other characters)
617 + *
618 + * @param string $pValue UTF-8 encoded string
619 + * @return string
620 + */
621 + public static function StrToTitle($pValue = '')
622 + {
623 + if (function_exists('mb_convert_case')) {
624 + return mb_convert_case($pValue, MB_CASE_TITLE, "UTF-8");
625 + }
626 + return ucwords($pValue);
627 + }
634 628
635 629 public static function mb_is_upper($char)
636 630 {
637 631 return mb_strtolower($char, "UTF-8") != $char;
@@ -640,24 +634,24 @@
640 634 public static function mb_str_split($string)
641 635 {
642 636 # Split at all position not after the start: ^
643 637 # and not before the end: $
644 - return preg_split('/(?<!^)(?!$)/u', $string);
638 + return preg_split('/(?<!^)(?!$)/u', $string );
645 639 }
646 640
647 - /**
648 - * Reverse the case of a string, so that all uppercase characters become lowercase
641 + /**
642 + * Reverse the case of a string, so that all uppercase characters become lowercase
649 643 * and all lowercase characters become uppercase
650 - *
651 - * @param string $pValue UTF-8 encoded string
652 - * @return string
653 - */
654 - public static function StrCaseReverse($pValue = '')
655 - {
644 + *
645 + * @param string $pValue UTF-8 encoded string
646 + * @return string
647 + */
648 + public static function StrCaseReverse($pValue = '')
649 + {
656 650 if (self::getIsMbstringEnabled()) {
657 651 $characters = self::mb_str_split($pValue);
658 - foreach ($characters as &$character) {
659 - if (self::mb_is_upper($character)) {
652 + foreach($characters as &$character) {
653 + if(self::mb_is_upper($character)) {
660 654 $character = mb_strtolower($character, 'UTF-8');
661 655 } else {
662 656 $character = mb_strtoupper($character, 'UTF-8');
663 657 }
@@ -662,158 +656,156 @@
662 656 $character = mb_strtoupper($character, 'UTF-8');
663 657 }
664 658 }
665 659 return implode('', $characters);
666 - }
667 - return strtolower($pValue) ^ strtoupper($pValue) ^ $pValue;
668 - }
660 + }
661 + return strtolower($pValue) ^ strtoupper($pValue) ^ $pValue;
662 + }
669 663
670 - /**
671 - * Identify whether a string contains a fractional numeric value,
672 - * and convert it to a numeric if it is
673 - *
674 - * @param string &$operand string value to test
675 - * @return boolean
676 - */
677 - public static function convertToNumberIfFraction(&$operand)
678 - {
679 - if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
680 - $sign = ($match[1] == '-') ? '-' : '+';
681 - $fractionFormula = '='.$sign.$match[2].$sign.$match[3];
682 - $operand = PHPExcel_Calculation::getInstance()->_calculateFormulaValue($fractionFormula);
683 - return true;
684 - }
685 - return false;
686 - } // function convertToNumberIfFraction()
664 + /**
665 + * Identify whether a string contains a fractional numeric value,
666 + * and convert it to a numeric if it is
667 + *
668 + * @param string &$operand string value to test
669 + * @return boolean
670 + */
671 + public static function convertToNumberIfFraction(&$operand) {
672 + if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
673 + $sign = ($match[1] == '-') ? '-' : '+';
674 + $fractionFormula = '='.$sign.$match[2].$sign.$match[3];
675 + $operand = PHPExcel_Calculation::getInstance()->_calculateFormulaValue($fractionFormula);
676 + return true;
677 + }
678 + return false;
679 + } // function convertToNumberIfFraction()
687 680
688 - /**
689 - * Get the decimal separator. If it has not yet been set explicitly, try to obtain number
690 - * formatting information from locale.
691 - *
692 - * @return string
693 - */
694 - public static function getDecimalSeparator()
695 - {
696 - if (!isset(self::$decimalSeparator)) {
697 - $localeconv = localeconv();
698 - self::$decimalSeparator = ($localeconv['decimal_point'] != '')
699 - ? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
681 + /**
682 + * Get the decimal separator. If it has not yet been set explicitly, try to obtain number
683 + * formatting information from locale.
684 + *
685 + * @return string
686 + */
687 + public static function getDecimalSeparator()
688 + {
689 + if (!isset(self::$_decimalSeparator)) {
690 + $localeconv = localeconv();
691 + self::$_decimalSeparator = ($localeconv['decimal_point'] != '')
692 + ? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
700 693
701 - if (self::$decimalSeparator == '') {
702 - // Default to .
703 - self::$decimalSeparator = '.';
704 - }
705 - }
706 - return self::$decimalSeparator;
707 - }
694 + if (self::$_decimalSeparator == '') {
695 + // Default to .
696 + self::$_decimalSeparator = '.';
697 + }
698 + }
699 + return self::$_decimalSeparator;
700 + }
708 701
709 - /**
710 - * Set the decimal separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
711 - * to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
712 - *
713 - * @param string $pValue Character for decimal separator
714 - */
715 - public static function setDecimalSeparator($pValue = '.')
716 - {
717 - self::$decimalSeparator = $pValue;
718 - }
702 + /**
703 + * Set the decimal separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
704 + * to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
705 + *
706 + * @param string $pValue Character for decimal separator
707 + */
708 + public static function setDecimalSeparator($pValue = '.')
709 + {
710 + self::$_decimalSeparator = $pValue;
711 + }
719 712
720 - /**
721 - * Get the thousands separator. If it has not yet been set explicitly, try to obtain number
722 - * formatting information from locale.
723 - *
724 - * @return string
725 - */
726 - public static function getThousandsSeparator()
727 - {
728 - if (!isset(self::$thousandsSeparator)) {
729 - $localeconv = localeconv();
730 - self::$thousandsSeparator = ($localeconv['thousands_sep'] != '')
731 - ? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
713 + /**
714 + * Get the thousands separator. If it has not yet been set explicitly, try to obtain number
715 + * formatting information from locale.
716 + *
717 + * @return string
718 + */
719 + public static function getThousandsSeparator()
720 + {
721 + if (!isset(self::$_thousandsSeparator)) {
722 + $localeconv = localeconv();
723 + self::$_thousandsSeparator = ($localeconv['thousands_sep'] != '')
724 + ? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
732 725
733 - if (self::$thousandsSeparator == '') {
734 - // Default to .
735 - self::$thousandsSeparator = ',';
736 - }
737 - }
738 - return self::$thousandsSeparator;
739 - }
726 + if (self::$_thousandsSeparator == '') {
727 + // Default to .
728 + self::$_thousandsSeparator = ',';
729 + }
730 + }
731 + return self::$_thousandsSeparator;
732 + }
740 733
741 - /**
742 - * Set the thousands separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
743 - * to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
744 - *
745 - * @param string $pValue Character for thousands separator
746 - */
747 - public static function setThousandsSeparator($pValue = ',')
748 - {
749 - self::$thousandsSeparator = $pValue;
750 - }
734 + /**
735 + * Set the thousands separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
736 + * to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
737 + *
738 + * @param string $pValue Character for thousands separator
739 + */
740 + public static function setThousandsSeparator($pValue = ',')
741 + {
742 + self::$_thousandsSeparator = $pValue;
743 + }
751 744
752 - /**
753 - * Get the currency code. If it has not yet been set explicitly, try to obtain the
754 - * symbol information from locale.
755 - *
756 - * @return string
757 - */
758 - public static function getCurrencyCode()
759 - {
760 - if (!isset(self::$currencyCode)) {
761 - $localeconv = localeconv();
762 - self::$currencyCode = ($localeconv['currency_symbol'] != '')
763 - ? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol'];
745 + /**
746 + * Get the currency code. If it has not yet been set explicitly, try to obtain the
747 + * symbol information from locale.
748 + *
749 + * @return string
750 + */
751 + public static function getCurrencyCode()
752 + {
753 + if (!isset(self::$_currencyCode)) {
754 + $localeconv = localeconv();
755 + self::$_currencyCode = ($localeconv['currency_symbol'] != '')
756 + ? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol'];
764 757
765 - if (self::$currencyCode == '') {
766 - // Default to $
767 - self::$currencyCode = '$';
768 - }
769 - }
770 - return self::$currencyCode;
771 - }
758 + if (self::$_currencyCode == '') {
759 + // Default to $
760 + self::$_currencyCode = '$';
761 + }
762 + }
763 + return self::$_currencyCode;
764 + }
772 765
773 - /**
774 - * Set the currency code. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
775 - * to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
776 - *
777 - * @param string $pValue Character for currency code
778 - */
779 - public static function setCurrencyCode($pValue = '$')
780 - {
781 - self::$currencyCode = $pValue;
782 - }
766 + /**
767 + * Set the currency code. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
768 + * to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
769 + *
770 + * @param string $pValue Character for currency code
771 + */
772 + public static function setCurrencyCode($pValue = '$')
773 + {
774 + self::$_currencyCode = $pValue;
775 + }
783 776
784 - /**
785 - * Convert SYLK encoded string to UTF-8
786 - *
787 - * @param string $pValue
788 - * @return string UTF-8 encoded string
789 - */
790 - public static function SYLKtoUTF8($pValue = '')
791 - {
792 - // If there is no escape character in the string there is nothing to do
793 - if (strpos($pValue, '') === false) {
794 - return $pValue;
795 - }
777 + /**
778 + * Convert SYLK encoded string to UTF-8
779 + *
780 + * @param string $pValue
781 + * @return string UTF-8 encoded string
782 + */
783 + public static function SYLKtoUTF8($pValue = '')
784 + {
785 + // If there is no escape character in the string there is nothing to do
786 + if (strpos($pValue, '') === false) {
787 + return $pValue;
788 + }
796 789
797 - foreach (self::$SYLKCharacters as $k => $v) {
798 - $pValue = str_replace($k, $v, $pValue);
799 - }
790 + foreach (self::$_SYLKCharacters as $k => $v) {
791 + $pValue = str_replace($k, $v, $pValue);
792 + }
800 793
801 - return $pValue;
802 - }
794 + return $pValue;
795 + }
803 796
804 - /**
805 - * Retrieve any leading numeric part of a string, or return the full string if no leading numeric
806 - * (handles basic integer or float, but not exponent or non decimal)
807 - *
808 - * @param string $value
809 - * @return mixed string or only the leading numeric part of the string
810 - */
811 - public static function testStringAsNumeric($value)
812 - {
813 - if (is_numeric($value)) {
814 - return $value;
815 - }
816 - $v = floatval($value);
817 - return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
818 - }
797 + /**
798 + * Retrieve any leading numeric part of a string, or return the full string if no leading numeric
799 + * (handles basic integer or float, but not exponent or non decimal)
800 + *
801 + * @param string $value
802 + * @return mixed string or only the leading numeric part of the string
803 + */
804 + public static function testStringAsNumeric($value)
805 + {
806 + if (is_numeric($value))
807 + return $value;
808 + $v = floatval($value);
809 + return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
810 + }
819 811 }