2.11.11.3 release
[phpmyadmin/arisferyanto.git] / libraries / tcpdf / html_entity_decode_php4.php
blob4930c21e69d4f50a9e9d08f16b7135438f751831
1 <?php
2 //============================================================+
3 // File name : html_entity_decode_php4.php
4 // Begin : 2006-06-22
5 // Last Update : 2006-06-22
6 // Author : Nicola Asuni
7 // Version : 1.0.000
8 // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
9 //
10 // Description : This is a PHP4 function that redefine the
11 // standard html_entity_decode function to support
12 // UTF-8 encoding.
14 //============================================================+
16 /**
17 * TCPDF Class.
18 * @package com.tecnick.tcpdf
22 /**
23 * Returns the UTF-8 string corresponding to unicode value.
24 * @param $num unicode value to convert.
25 * @return string converted
27 function code_to_utf8($num) {
28 if ($num <= 0x7F) {
29 return chr($num);
30 } elseif ($num <= 0x7FF) {
31 return chr(($num >> 0x06) + 0xC0).chr(($num & 0x3F) + 128);
32 } elseif ($num <= 0xFFFF) {
33 return chr(($num >> 0x0C) + 0xE0).chr((($num >> 0x06) & 0x3F) + 0x80).chr(($num & 0x3F) + 0x80);
34 } elseif ($num <= 0x1FFFFF) {
35 return chr(($num >> 0x12) + 0xF0).chr((($num >> 0x0C) & 0x3F) + 0x80).chr((($num >> 0x06) & 0x3F) + 0x80).chr(($num & 0x3F) + 0x80);
37 return ' '; // default value
40 /**
41 * Reverse function for htmlentities.
42 * Convert entities in UTF-8.
43 * @param $text_to_convert Text to convert.
44 * @return string converted
46 function html_entity_decode_php4($text_to_convert) {
47 $htmlentities_table = array (
48 "&Aacute;" => "".chr(195).chr(129)."",
49 "&aacute;" => "".chr(195).chr(161)."",
50 "&Acirc;" => "".chr(195).chr(130)."",
51 "&acirc;" => "".chr(195).chr(162)."",
52 "&acute;" => "".chr(194).chr(180)."",
53 "&AElig;" => "".chr(195).chr(134)."",
54 "&aelig;" => "".chr(195).chr(166)."",
55 "&Agrave;" => "".chr(195).chr(128)."",
56 "&agrave;" => "".chr(195).chr(160)."",
57 "&alefsym;" => "".chr(226).chr(132).chr(181)."",
58 "&Alpha;" => "".chr(206).chr(145)."",
59 "&alpha;" => "".chr(206).chr(177)."",
60 "&amp;" => "".chr(38)."",
61 "&and;" => "".chr(226).chr(136).chr(167)."",
62 "&ang;" => "".chr(226).chr(136).chr(160)."",
63 "&Aring;" => "".chr(195).chr(133)."",
64 "&aring;" => "".chr(195).chr(165)."",
65 "&asymp;" => "".chr(226).chr(137).chr(136)."",
66 "&Atilde;" => "".chr(195).chr(131)."",
67 "&atilde;" => "".chr(195).chr(163)."",
68 "&Auml;" => "".chr(195).chr(132)."",
69 "&auml;" => "".chr(195).chr(164)."",
70 "&bdquo;" => "".chr(226).chr(128).chr(158)."",
71 "&Beta;" => "".chr(206).chr(146)."",
72 "&beta;" => "".chr(206).chr(178)."",
73 "&brvbar;" => "".chr(194).chr(166)."",
74 "&bull;" => "".chr(226).chr(128).chr(162)."",
75 "&cap;" => "".chr(226).chr(136).chr(169)."",
76 "&Ccedil;" => "".chr(195).chr(135)."",
77 "&ccedil;" => "".chr(195).chr(167)."",
78 "&cedil;" => "".chr(194).chr(184)."",
79 "&cent;" => "".chr(194).chr(162)."",
80 "&Chi;" => "".chr(206).chr(167)."",
81 "&chi;" => "".chr(207).chr(135)."",
82 "&circ;" => "".chr(203).chr(134)."",
83 "&clubs;" => "".chr(226).chr(153).chr(163)."",
84 "&cong;" => "".chr(226).chr(137).chr(133)."",
85 "&copy;" => "".chr(194).chr(169)."",
86 "&crarr;" => "".chr(226).chr(134).chr(181)."",
87 "&cup;" => "".chr(226).chr(136).chr(170)."",
88 "&curren;" => "".chr(194).chr(164)."",
89 "&dagger;" => "".chr(226).chr(128).chr(160)."",
90 "&Dagger;" => "".chr(226).chr(128).chr(161)."",
91 "&darr;" => "".chr(226).chr(134).chr(147)."",
92 "&dArr;" => "".chr(226).chr(135).chr(147)."",
93 "&deg;" => "".chr(194).chr(176)."",
94 "&Delta;" => "".chr(206).chr(148)."",
95 "&delta;" => "".chr(206).chr(180)."",
96 "&diams;" => "".chr(226).chr(153).chr(166)."",
97 "&divide;" => "".chr(195).chr(183)."",
98 "&Eacute;" => "".chr(195).chr(137)."",
99 "&eacute;" => "".chr(195).chr(169)."",
100 "&Ecirc;" => "".chr(195).chr(138)."",
101 "&ecirc;" => "".chr(195).chr(170)."",
102 "&Egrave;" => "".chr(195).chr(136)."",
103 "&egrave;" => "".chr(195).chr(168)."",
104 "&empty;" => "".chr(226).chr(136).chr(133)."",
105 "&emsp;" => "".chr(226).chr(128).chr(131)."",
106 "&ensp;" => "".chr(226).chr(128).chr(130)."",
107 "&Epsilon;" => "".chr(206).chr(149)."",
108 "&epsilon;" => "".chr(206).chr(181)."",
109 "&equiv;" => "".chr(226).chr(137).chr(161)."",
110 "&Eta;" => "".chr(206).chr(151)."",
111 "&eta;" => "".chr(206).chr(183)."",
112 "&ETH;" => "".chr(195).chr(144)."",
113 "&eth;" => "".chr(195).chr(176)."",
114 "&Euml;" => "".chr(195).chr(139)."",
115 "&euml;" => "".chr(195).chr(171)."",
116 "&euro;" => "".chr(226).chr(130).chr(172)."",
117 "&exist;" => "".chr(226).chr(136).chr(131)."",
118 "&fnof;" => "".chr(198).chr(146)."",
119 "&forall;" => "".chr(226).chr(136).chr(128)."",
120 "&frac12;" => "".chr(194).chr(189)."",
121 "&frac14;" => "".chr(194).chr(188)."",
122 "&frac34;" => "".chr(194).chr(190)."",
123 "&frasl;" => "".chr(226).chr(129).chr(132)."",
124 "&Gamma;" => "".chr(206).chr(147)."",
125 "&gamma;" => "".chr(206).chr(179)."",
126 "&ge;" => "".chr(226).chr(137).chr(165)."",
127 "&harr;" => "".chr(226).chr(134).chr(148)."",
128 "&hArr;" => "".chr(226).chr(135).chr(148)."",
129 "&hearts;" => "".chr(226).chr(153).chr(165)."",
130 "&hellip;" => "".chr(226).chr(128).chr(166)."",
131 "&Iacute;" => "".chr(195).chr(141)."",
132 "&iacute;" => "".chr(195).chr(173)."",
133 "&Icirc;" => "".chr(195).chr(142)."",
134 "&icirc;" => "".chr(195).chr(174)."",
135 "&iexcl;" => "".chr(194).chr(161)."",
136 "&Igrave;" => "".chr(195).chr(140)."",
137 "&igrave;" => "".chr(195).chr(172)."",
138 "&image;" => "".chr(226).chr(132).chr(145)."",
139 "&infin;" => "".chr(226).chr(136).chr(158)."",
140 "&int;" => "".chr(226).chr(136).chr(171)."",
141 "&Iota;" => "".chr(206).chr(153)."",
142 "&iota;" => "".chr(206).chr(185)."",
143 "&iquest;" => "".chr(194).chr(191)."",
144 "&isin;" => "".chr(226).chr(136).chr(136)."",
145 "&Iuml;" => "".chr(195).chr(143)."",
146 "&iuml;" => "".chr(195).chr(175)."",
147 "&Kappa;" => "".chr(206).chr(154)."",
148 "&kappa;" => "".chr(206).chr(186)."",
149 "&Lambda;" => "".chr(206).chr(155)."",
150 "&lambda;" => "".chr(206).chr(187)."",
151 "&lang;" => "".chr(226).chr(140).chr(169)."",
152 "&laquo;" => "".chr(194).chr(171)."",
153 "&larr;" => "".chr(226).chr(134).chr(144)."",
154 "&lArr;" => "".chr(226).chr(135).chr(144)."",
155 "&lceil;" => "".chr(226).chr(140).chr(136)."",
156 "&ldquo;" => "".chr(226).chr(128).chr(156)."",
157 "&le;" => "".chr(226).chr(137).chr(164)."",
158 "&lfloor;" => "".chr(226).chr(140).chr(138)."",
159 "&lowast;" => "".chr(226).chr(136).chr(151)."",
160 "&loz;" => "".chr(226).chr(151).chr(138)."",
161 "&lrm;" => "".chr(226).chr(128).chr(142)."",
162 "&lsaquo;" => "".chr(226).chr(128).chr(185)."",
163 "&lsquo;" => "".chr(226).chr(128).chr(152)."",
164 "&macr;" => "".chr(194).chr(175)."",
165 "&mdash;" => "".chr(226).chr(128).chr(148)."",
166 "&micro;" => "".chr(194).chr(181)."",
167 "&middot;" => "".chr(194).chr(183)."",
168 "&minus;" => "".chr(226).chr(136).chr(146)."",
169 "&Mu;" => "".chr(206).chr(156)."",
170 "&mu;" => "".chr(206).chr(188)."",
171 "&nabla;" => "".chr(226).chr(136).chr(135)."",
172 "&nbsp;" => "".chr(194).chr(160)."",
173 "&ndash;" => "".chr(226).chr(128).chr(147)."",
174 "&ne;" => "".chr(226).chr(137).chr(160)."",
175 "&ni;" => "".chr(226).chr(136).chr(139)."",
176 "&not;" => "".chr(194).chr(172)."",
177 "&notin;" => "".chr(226).chr(136).chr(137)."",
178 "&nsub;" => "".chr(226).chr(138).chr(132)."",
179 "&Ntilde;" => "".chr(195).chr(145)."",
180 "&ntilde;" => "".chr(195).chr(177)."",
181 "&Nu;" => "".chr(206).chr(157)."",
182 "&nu;" => "".chr(206).chr(189)."",
183 "&Oacute;" => "".chr(195).chr(147)."",
184 "&oacute;" => "".chr(195).chr(179)."",
185 "&Ocirc;" => "".chr(195).chr(148)."",
186 "&ocirc;" => "".chr(195).chr(180)."",
187 "&OElig;" => "".chr(197).chr(146)."",
188 "&oelig;" => "".chr(197).chr(147)."",
189 "&Ograve;" => "".chr(195).chr(146)."",
190 "&ograve;" => "".chr(195).chr(178)."",
191 "&oline;" => "".chr(226).chr(128).chr(190)."",
192 "&Omega;" => "".chr(206).chr(169)."",
193 "&omega;" => "".chr(207).chr(137)."",
194 "&Omicron;" => "".chr(206).chr(159)."",
195 "&omicron;" => "".chr(206).chr(191)."",
196 "&oplus;" => "".chr(226).chr(138).chr(149)."",
197 "&or;" => "".chr(226).chr(136).chr(168)."",
198 "&ordf;" => "".chr(194).chr(170)."",
199 "&ordm;" => "".chr(194).chr(186)."",
200 "&Oslash;" => "".chr(195).chr(152)."",
201 "&oslash;" => "".chr(195).chr(184)."",
202 "&Otilde;" => "".chr(195).chr(149)."",
203 "&otilde;" => "".chr(195).chr(181)."",
204 "&otimes;" => "".chr(226).chr(138).chr(151)."",
205 "&Ouml;" => "".chr(195).chr(150)."",
206 "&ouml;" => "".chr(195).chr(182)."",
207 "&para;" => "".chr(194).chr(182)."",
208 "&part;" => "".chr(226).chr(136).chr(130)."",
209 "&permil;" => "".chr(226).chr(128).chr(176)."",
210 "&perp;" => "".chr(226).chr(138).chr(165)."",
211 "&Phi;" => "".chr(206).chr(166)."",
212 "&phi;" => "".chr(207).chr(134)."",
213 "&Pi;" => "".chr(206).chr(160)."",
214 "&pi;" => "".chr(207).chr(128)."",
215 "&piv;" => "".chr(207).chr(150)."",
216 "&plusmn;" => "".chr(194).chr(177)."",
217 "&pound;" => "".chr(194).chr(163)."",
218 "&prime;" => "".chr(226).chr(128).chr(178)."",
219 "&Prime;" => "".chr(226).chr(128).chr(179)."",
220 "&prod;" => "".chr(226).chr(136).chr(143)."",
221 "&prop;" => "".chr(226).chr(136).chr(157)."",
222 "&Psi;" => "".chr(206).chr(168)."",
223 "&psi;" => "".chr(207).chr(136)."",
224 "&radic;" => "".chr(226).chr(136).chr(154)."",
225 "&rang;" => "".chr(226).chr(140).chr(170)."",
226 "&raquo;" => "".chr(194).chr(187)."",
227 "&rarr;" => "".chr(226).chr(134).chr(146)."",
228 "&rArr;" => "".chr(226).chr(135).chr(146)."",
229 "&rceil;" => "".chr(226).chr(140).chr(137)."",
230 "&rdquo;" => "".chr(226).chr(128).chr(157)."",
231 "&real;" => "".chr(226).chr(132).chr(156)."",
232 "&reg;" => "".chr(194).chr(174)."",
233 "&rfloor;" => "".chr(226).chr(140).chr(139)."",
234 "&Rho;" => "".chr(206).chr(161)."",
235 "&rho;" => "".chr(207).chr(129)."",
236 "&rlm;" => "".chr(226).chr(128).chr(143)."",
237 "&rsaquo;" => "".chr(226).chr(128).chr(186)."",
238 "&rsquo;" => "".chr(226).chr(128).chr(153)."",
239 "&sbquo;" => "".chr(226).chr(128).chr(154)."",
240 "&Scaron;" => "".chr(197).chr(160)."",
241 "&scaron;" => "".chr(197).chr(161)."",
242 "&sdot;" => "".chr(226).chr(139).chr(133)."",
243 "&sect;" => "".chr(194).chr(167)."",
244 "&shy;" => "".chr(194).chr(173)."",
245 "&Sigma;" => "".chr(206).chr(163)."",
246 "&sigma;" => "".chr(207).chr(131)."",
247 "&sigmaf;" => "".chr(207).chr(130)."",
248 "&sim;" => "".chr(226).chr(136).chr(188)."",
249 "&spades;" => "".chr(226).chr(153).chr(160)."",
250 "&sub;" => "".chr(226).chr(138).chr(130)."",
251 "&sube;" => "".chr(226).chr(138).chr(134)."",
252 "&sum;" => "".chr(226).chr(136).chr(145)."",
253 "&sup1;" => "".chr(194).chr(185)."",
254 "&sup2;" => "".chr(194).chr(178)."",
255 "&sup3;" => "".chr(194).chr(179)."",
256 "&sup;" => "".chr(226).chr(138).chr(131)."",
257 "&supe;" => "".chr(226).chr(138).chr(135)."",
258 "&szlig;" => "".chr(195).chr(159)."",
259 "&Tau;" => "".chr(206).chr(164)."",
260 "&tau;" => "".chr(207).chr(132)."",
261 "&there4;" => "".chr(226).chr(136).chr(180)."",
262 "&Theta;" => "".chr(206).chr(152)."",
263 "&theta;" => "".chr(206).chr(184)."",
264 "&thetasym;" => "".chr(207).chr(145)."",
265 "&thinsp;" => "".chr(226).chr(128).chr(137)."",
266 "&THORN;" => "".chr(195).chr(158)."",
267 "&thorn;" => "".chr(195).chr(190)."",
268 "&tilde;" => "".chr(203).chr(156)."",
269 "&times;" => "".chr(195).chr(151)."",
270 "&trade;" => "".chr(226).chr(132).chr(162)."",
271 "&Uacute;" => "".chr(195).chr(154)."",
272 "&uacute;" => "".chr(195).chr(186)."",
273 "&uarr;" => "".chr(226).chr(134).chr(145)."",
274 "&uArr;" => "".chr(226).chr(135).chr(145)."",
275 "&Ucirc;" => "".chr(195).chr(155)."",
276 "&ucirc;" => "".chr(195).chr(187)."",
277 "&Ugrave;" => "".chr(195).chr(153)."",
278 "&ugrave;" => "".chr(195).chr(185)."",
279 "&uml;" => "".chr(194).chr(168)."",
280 "&upsih;" => "".chr(207).chr(146)."",
281 "&Upsilon;" => "".chr(206).chr(165)."",
282 "&upsilon;" => "".chr(207).chr(133)."",
283 "&Uuml;" => "".chr(195).chr(156)."",
284 "&uuml;" => "".chr(195).chr(188)."",
285 "&weierp;" => "".chr(226).chr(132).chr(152)."",
286 "&Xi;" => "".chr(206).chr(158)."",
287 "&xi;" => "".chr(206).chr(190)."",
288 "&Yacute;" => "".chr(195).chr(157)."",
289 "&yacute;" => "".chr(195).chr(189)."",
290 "&yen;" => "".chr(194).chr(165)."",
291 "&yuml;" => "".chr(195).chr(191)."",
292 "&Yuml;" => "".chr(197).chr(184)."",
293 "&Zeta;" => "".chr(206).chr(150)."",
294 "&zeta;" => "".chr(206).chr(182)."",
295 "&zwj;" => "".chr(226).chr(128).chr(141)."",
296 "&zwnj;" => "".chr(226).chr(128).chr(140)."",
297 "&gt;" => ">",
298 "&lt;" => "<"
300 $return_text = strtr($text_to_convert, $htmlentities_table);
301 $return_text = preg_replace('~&#x([0-9a-f]+);~ei', 'code_to_utf8(hexdec("\\1"))', $return_text);
302 $return_text = preg_replace('~&#([0-9]+);~e', 'code_to_utf8(\\1)', $return_text);
303 return $return_text;
306 //============================================================+
307 // END OF FILE
308 //============================================================+