2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <cstring> // for strlen()
22 #include "xhtml-entities.h"
36 * Implementation of the XHTML Entity matching
38 struct XHTMLEntityLookup
40 const char* const entityName; // XHTML Named Entity string
41 const char* const entityCode; // Corresponding UTF-8
44 /* table of html name entities supported in DALi
46 * these are stored as pair with Named entity as Key and
49 const XHTMLEntityLookup XHTMLEntityLookupTable[] =
51 { ""\0" ,"\x22\0" },
52 { "&\0" ,"\x26\0" },
53 { "'\0" ,"\x27\0" },
54 { "<\0" ,"\x3c\0" },
55 { ">\0" ,"\x3e\0" },
56 { " \0" ,"\xc2\xa0\0" },
57 { "¡\0" ,"\xc2\xa1\0" },
58 { "¢\0" ,"\xc2\xa2\0" },
59 { "£\0" ,"\xc2\xa3\0" },
60 { "¤\0" ,"\xc2\xa4\0" },
61 { "¥\0" ,"\xc2\xa5\0" },
62 { "¦\0" ,"\xc2\xa6\0" },
63 { "§\0" ,"\xc2\xa7\0" },
64 { "¨\0" ,"\xc2\xa8\0" },
65 { "©\0" ,"\xc2\xa9\0" },
66 { "ª\0" ,"\xc2\xaa\0" },
67 { "«\0" ,"\xc2\xab\0" },
68 { "¬\0" ,"\xc2\xac\0" },
69 { "­\0" ,"\xc2\xad\0" },
70 { "®\0" ,"\xc2\xae\0" },
71 { "¯\0" ,"\xc2\xaf\0" },
72 { "°\0" ,"\xc2\xb0\0" },
73 { "±\0" ,"\xc2\xb1\0" },
74 { "²\0" ,"\xc2\xb2\0" },
75 { "³\0" ,"\xc2\xb3\0" },
76 { "´\0" ,"\xc2\xb4\0" },
77 { "µ\0" ,"\xc2\xb5\0" },
78 { "¶\0" ,"\xc2\xb6\0" },
79 { "·\0" ,"\xc2\xb7\0" },
80 { "¸\0" ,"\xc2\xb8\0" },
81 { "¹\0" ,"\xc2\xb9\0" },
82 { "º\0" ,"\xc2\xba\0" },
83 { "»\0" ,"\xc2\xbb\0" },
84 { "¼\0" ,"\xc2\xbc\0" },
85 { "½\0" ,"\xc2\xbd\0" },
86 { "¾\0" ,"\xc2\xbe\0" },
87 { "¿\0" ,"\xc2\xbf\0" },
88 { "À\0" ,"\xc3\x80\0" },
89 { "Á\0" ,"\xc3\x81\0" },
90 { "Â\0" ,"\xc3\x82\0" },
91 { "Ã\0" ,"\xc3\x83\0" },
92 { "Ä\0" ,"\xc3\x84\0" },
93 { "Å\0" ,"\xc3\x85\0" },
94 { "Æ\0" ,"\xc3\x86\0" },
95 { "Ç\0" ,"\xc3\x87\0" },
96 { "È\0" ,"\xc3\x88\0" },
97 { "É\0" ,"\xc3\x89\0" },
98 { "Ê\0" ,"\xc3\x8a\0" },
99 { "Ë\0" ,"\xc3\x8b\0" },
100 { "Ì\0" ,"\xc3\x8c\0" },
101 { "Í\0" ,"\xc3\x8d\0" },
102 { "Î\0" ,"\xc3\x8e\0" },
103 { "Ï\0" ,"\xc3\x8f\0" },
104 { "Ð\0" ,"\xc3\x90\0" },
105 { "Ñ\0" ,"\xc3\x91\0" },
106 { "Ò\0" ,"\xc3\x92\0" },
107 { "Ó\0" ,"\xc3\x93\0" },
108 { "Ô\0" ,"\xc3\x94\0" },
109 { "Õ\0" ,"\xc3\x95\0" },
110 { "Ö\0" ,"\xc3\x96\0" },
111 { "×\0" ,"\xc3\x97\0" },
112 { "Ø\0" ,"\xc3\x98\0" },
113 { "Ù\0" ,"\xc3\x99\0" },
114 { "Ú\0" ,"\xc3\x9a\0" },
115 { "Û\0" ,"\xc3\x9b\0" },
116 { "Ü\0" ,"\xc3\x9c\0" },
117 { "Ý\0" ,"\xc3\x9d\0" },
118 { "Þ\0" ,"\xc3\x9e\0" },
119 { "ß\0" ,"\xc3\x9f\0" },
120 { "à\0" ,"\xc3\xa0\0" },
121 { "á\0" ,"\xc3\xa1\0" },
122 { "â\0" ,"\xc3\xa2\0" },
123 { "ã\0" ,"\xc3\xa3\0" },
124 { "ä\0" ,"\xc3\xa4\0" },
125 { "å\0" ,"\xc3\xa5\0" },
126 { "æ\0" ,"\xc3\xa6\0" },
127 { "ç\0" ,"\xc3\xa7\0" },
128 { "è\0" ,"\xc3\xa8\0" },
129 { "é\0" ,"\xc3\xa9\0" },
130 { "ê\0" ,"\xc3\xaa\0" },
131 { "ë\0" ,"\xc3\xab\0" },
132 { "ì\0" ,"\xc3\xac\0" },
133 { "í\0" ,"\xc3\xad\0" },
134 { "î\0" ,"\xc3\xae\0" },
135 { "ï\0" ,"\xc3\xaf\0" },
136 { "ð\0" ,"\xc3\xb0\0" },
137 { "ñ\0" ,"\xc3\xb1\0" },
138 { "ò\0" ,"\xc3\xb2\0" },
139 { "ó\0" ,"\xc3\xb3\0" },
140 { "ô\0" ,"\xc3\xb4\0" },
141 { "õ\0" ,"\xc3\xb5\0" },
142 { "ö\0" ,"\xc3\xb6\0" },
143 { "÷\0" ,"\xc3\xb7\0" },
144 { "ø\0" ,"\xc3\xb8\0" },
145 { "ù\0" ,"\xc3\xb9\0" },
146 { "ú\0" ,"\xc3\xba\0" },
147 { "û\0" ,"\xc3\xbb\0" },
148 { "ü\0" ,"\xc3\xbc\0" },
149 { "ý\0" ,"\xc3\xbd\0" },
150 { "þ\0" ,"\xc3\xbe\0" },
151 { "ÿ\0" ,"\xc3\xbf\0" },
152 { "Œ\0" ,"\xc5\x92\0" },
153 { "œ\0" ,"\xc5\x93\0" },
154 { "Š\0" ,"\xc5\xa0\0" },
155 { "š\0" ,"\xc5\xa1\0" },
156 { "Ÿ\0" ,"\xc5\xb8\0" },
157 { "ƒ\0" ,"\xc6\x92\0" },
158 { "ˆ\0" ,"\xcb\x86\0" },
159 { "˜\0" ,"\xcb\x9c\0" },
160 { "Α\0" ,"\xce\x91\0" },
161 { "Β\0" ,"\xce\x92\0" },
162 { "Γ\0" ,"\xce\x93\0" },
163 { "Δ\0" ,"\xce\x94\0" },
164 { "Ε\0" ,"\xce\x95\0" },
165 { "Ζ\0" ,"\xce\x96\0" },
166 { "Η\0" ,"\xce\x97\0" },
167 { "Θ\0" ,"\xce\x98\0" },
168 { "Ι\0" ,"\xce\x99\0" },
169 { "Κ\0" ,"\xce\x9a\0" },
170 { "Λ\0" ,"\xce\x9b\0" },
171 { "Μ\0" ,"\xce\x9c\0" },
172 { "Ν\0" ,"\xce\x9d\0" },
173 { "Ξ\0" ,"\xce\x9e\0" },
174 { "Ο\0" ,"\xce\x9f\0" },
175 { "Π\0" ,"\xce\xa0\0" },
176 { "Ρ\0" ,"\xce\xa1\0" },
177 { "Σ\0" ,"\xce\xa3\0" },
178 { "Τ\0" ,"\xce\xa4\0" },
179 { "Υ\0" ,"\xce\xa5\0" },
180 { "Φ\0" ,"\xce\xa6\0" },
181 { "Χ\0" ,"\xce\xa7\0" },
182 { "Ψ\0" ,"\xce\xa8\0" },
183 { "Ω\0" ,"\xce\xa9\0" },
184 { "α\0" ,"\xce\xb1\0" },
185 { "β\0" ,"\xce\xb2\0" },
186 { "γ\0" ,"\xce\xb3\0" },
187 { "δ\0" ,"\xce\xb4\0" },
188 { "ε\0" ,"\xce\xb5\0" },
189 { "ζ\0" ,"\xce\xb6\0" },
190 { "η\0" ,"\xce\xb7\0" },
191 { "θ\0" ,"\xce\xb8\0" },
192 { "ι\0" ,"\xce\xb9\0" },
193 { "κ\0" ,"\xce\xba\0" },
194 { "λ\0" ,"\xce\xbb\0" },
195 { "μ\0" ,"\xce\xbc\0" },
196 { "ν\0" ,"\xce\xbd\0" },
197 { "ξ\0" ,"\xce\xbe\0" },
198 { "ο\0" ,"\xce\xbf\0" },
199 { "π\0" ,"\xcf\x80\0" },
200 { "ρ\0" ,"\xcf\x81\0" },
201 { "ς\0" ,"\xcf\x82\0" },
202 { "σ\0" ,"\xcf\x83\0" },
203 { "τ\0" ,"\xcf\x84\0" },
204 { "υ\0" ,"\xcf\x85\0" },
205 { "φ\0" ,"\xcf\x86\0" },
206 { "χ\0" ,"\xcf\x87\0" },
207 { "ψ\0" ,"\xcf\x88\0" },
208 { "ω\0" ,"\xcf\x89\0" },
209 { "ϑ\0","\xcf\x91\0" },
210 { "ϒ\0" ,"\xcf\x92\0" },
211 { "ϖ\0" ,"\xcf\x96\0" },
212 { " \0" ,"\xe2\x80\x82\0" },
213 { " \0" ,"\xe2\x80\x83\0" },
214 { " \0" ,"\xe2\x80\x89\0" },
215 { "‌\0" ,"\xe2\x80\x8c\0" },
216 { "‍\0" ,"\xe2\x80\x8d\0" },
217 { "‎\0" ,"\xe2\x80\x8e\0" },
218 { "‏\0" ,"\xe2\x80\x8f\0" },
219 { "–\0" ,"\xe2\x80\x93\0" },
220 { "—\0" ,"\xe2\x80\x94\0" },
221 { "‘\0" ,"\xe2\x80\x98\0" },
222 { "’\0" ,"\xe2\x80\x99\0" },
223 { "‚\0" ,"\xe2\x80\x9a\0" },
224 { "“\0" ,"\xe2\x80\x9c\0" },
225 { "”\0" ,"\xe2\x80\x9d\0" },
226 { "„\0" ,"\xe2\x80\x9e\0" },
227 { "†\0" ,"\xe2\x80\xa0\0" },
228 { "‡\0" ,"\xe2\x80\xa1\0" },
229 { "•\0" ,"\xe2\x80\xa2\0" },
230 { "…\0" ,"\xe2\x80\xa6\0" },
231 { "‰\0" ,"\xe2\x80\xb0\0" },
232 { "′\0" ,"\xe2\x80\xb2\0" },
233 { "″\0" ,"\xe2\x80\xb3\0" },
234 { "‹\0" ,"\xe2\x80\xb9\0" },
235 { "›\0" ,"\xe2\x80\xba\0" },
236 { "‾\0" ,"\xe2\x80\xbe\0" },
237 { "⁄\0" ,"\xe2\x81\x84\0" },
238 { "€\0" ,"\xe2\x82\xac\0" },
239 { "ℑ\0" ,"\xe2\x84\x91\0" },
240 { "℘\0" ,"\xe2\x84\x98\0" },
241 { "ℜ\0" ,"\xe2\x84\x9c\0" },
242 { "™\0" ,"\xe2\x84\xa2\0" },
243 { "ℵ\0" ,"\xe2\x84\xb5\0" },
244 { "←\0" ,"\xe2\x86\x90\0" },
245 { "↑\0" ,"\xe2\x86\x91\0" },
246 { "→\0" ,"\xe2\x86\x92\0" },
247 { "↓\0" ,"\xe2\x86\x93\0" },
248 { "↔\0" ,"\xe2\x86\x94\0" },
249 { "↵\0" ,"\xe2\x86\xb5\0" },
250 { "⇐\0" ,"\xe2\x87\x90\0" },
251 { "⇑\0" ,"\xe2\x87\x91\0" },
252 { "⇒\0" ,"\xe2\x87\x92\0" },
253 { "⇓\0" ,"\xe2\x87\x93\0" },
254 { "⇔\0" ,"\xe2\x87\x94\0" },
255 { "∀\0" ,"\xe2\x88\x80\0" },
256 { "∂\0" ,"\xe2\x88\x82\0" },
257 { "∃\0" ,"\xe2\x88\x83\0" },
258 { "∅\0" ,"\xe2\x88\x85\0" },
259 { "∇\0" ,"\xe2\x88\x87\0" },
260 { "∈\0" ,"\xe2\x88\x88\0" },
261 { "∉\0" ,"\xe2\x88\x89\0" },
262 { "∋\0" ,"\xe2\x88\x8b\0" },
263 { "∏\0" ,"\xe2\x88\x8f\0" },
264 { "∑\0" ,"\xe2\x88\x91\0" },
265 { "−\0" ,"\xe2\x88\x92\0" },
266 { "∗\0" ,"\xe2\x88\x97\0" },
267 { "√\0" ,"\xe2\x88\x9a\0" },
268 { "∝\0" ,"\xe2\x88\x9d\0" },
269 { "∞\0" ,"\xe2\x88\x9e\0" },
270 { "∠\0" ,"\xe2\x88\xa0\0" },
271 { "∧\0" ,"\xe2\x88\xa7\0" },
272 { "∨\0" ,"\xe2\x88\xa8\0" },
273 { "∩\0" ,"\xe2\x88\xa9\0" },
274 { "∪\0" ,"\xe2\x88\xaa\0" },
275 { "∫\0" ,"\xe2\x88\xab\0" },
276 { "∴\0" ,"\xe2\x88\xb4\0" },
277 { "∼\0" ,"\xe2\x88\xbc\0" },
278 { "≅\0" ,"\xe2\x89\x85\0" },
279 { "≈\0" ,"\xe2\x89\x88\0" },
280 { "≠\0" ,"\xe2\x89\xa0\0" },
281 { "≡\0" ,"\xe2\x89\xa1\0" },
282 { "≤\0" ,"\xe2\x89\xa4\0" },
283 { "≥\0" ,"\xe2\x89\xa5\0" },
284 { "⊂\0" ,"\xe2\x8a\x82\0" },
285 { "⊃\0" ,"\xe2\x8a\x83\0" },
286 { "⊄\0" ,"\xe2\x8a\x84\0" },
287 { "⊆\0" ,"\xe2\x8a\x86\0" },
288 { "⊇\0" ,"\xe2\x8a\x87\0" },
289 { "⊕\0" ,"\xe2\x8a\x95\0" },
290 { "⊗\0" ,"\xe2\x8a\x97\0" },
291 { "⊥\0" ,"\xe2\x8a\xa5\0" },
292 { "⋅\0" ,"\xe2\x8b\x85\0" },
293 { "⌈\0" ,"\xe2\x8c\x88\0" },
294 { "⌉\0" ,"\xe2\x8c\x89\0" },
295 { "⌊\0" ,"\xe2\x8c\x8a\0" },
296 { "⌋\0" ,"\xe2\x8c\x8b\0" },
297 { "◊\0" ,"\xe2\x97\x8a\0" },
298 { "♠\0" ,"\xe2\x99\xa0\0" },
299 { "♣\0" ,"\xe2\x99\xa3\0" },
300 { "♥\0" ,"\xe2\x99\xa5\0" },
301 { "♦\0" ,"\xe2\x99\xa6\0" },
302 { "⟨\0" ,"\xe2\x9f\xa8\0" },
303 { "⟩\0" ,"\xe2\x9f\xa9\0" }
306 const std::size_t XHTMLENTITY_LOOKUP_COUNT = (sizeof( XHTMLEntityLookupTable))/ (sizeof(XHTMLEntityLookup));
308 } // unnamed namespace
310 const char* const NamedEntityToUtf8( const char* const markupText, unsigned int len )
312 // finding if given XHTML named entity is supported or not
313 for( size_t i = 0; i < XHTMLENTITY_LOOKUP_COUNT ; ++i )
315 unsigned int entityLen = strlen(XHTMLEntityLookupTable[i].entityName);
316 if( len == entityLen )
318 if( strncmp( markupText, XHTMLEntityLookupTable[i].entityName, len ) == 0 ) // if named Entity found in table
320 return XHTMLEntityLookupTable[i].entityCode;
329 } // namespace Toolkit