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