9 ini_set(
'display_errors',
'stdout');
10 ini_set(
'display_startup_errors', 1);
11 ini_set(
'html_errors', 1);
15 assert_options(ASSERT_ACTIVE,
true);
16 assert_options(ASSERT_WARNING,
true);
17 assert_options(ASSERT_BAIL,
true);
19 mb_internal_encoding(
'UTF-8');
21 require_once
'alphanormalize.inc';
23 require_once
'html_entities_entitydefs.inc';
24 require_once
'html_entities_name2codepoint.inc';
25 require_once
'html_entities_codepoint2name.inc';
27 ?><!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
28 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:lang=
"fr">
30 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
31 <meta http-equiv=
"Reply-To" content=
"olivier.pirson.opi@gmail.com" />
33 <meta name=
"viewport" content=
"width=device-width, initial-scale=1" />
35 <title>alphanormalize_php – tests</title>
37 <meta name=
"copyright" content=
"© Olivier Pirson" />
38 <meta name=
"author" content=
"Olivier Pirson" />
39 <meta name=
"date-creation-yyyymmdd" content=
"20101005" />
40 <meta name=
"date-revision-yyyymmdd" content=
"20200617" />
41 <meta name=
"description" content=
"Simple functions to remove accents and replace non-alphanumeric characters." />
42 <meta name=
"keywords" content=
"PHP, character, accents, Greek" />
44 <style type=
"text/css">
50 table { border-collapse: collapse; }
52 tr { vertical-align: top; }
54 tr.sep { border-top:solid 3px silver; }
57 font-family: Dina, monospace;
64 border: solid 1px silver;
67 td.sep { background-color: silver; }
71 border-top: dotted 1px silver;
75 background-color: inherit;
79 background-color: inherit;
83 div { margin-top: 3ex; }
87 .center { text-align: center; }
89 .smallskip { margin-top: 1ex; }
90 .bigskip { margin-top: 3ex; }
91 .bigbigskip { margin-top: 6ex; }
92 .bigbigbigskip { margin-top: 9ex; }
94 .green { color: green; }
97 .surname { font-variant: small-caps; }
101 <h1><a rel=
"nofollow" href=
"https://bitbucket.org/OPiMedia/alphanormalize_php" style=
"text-decoration:none"><img src=
"https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2020/Jun/12/1411058763-4-alphanormalize_php-logo_avatar.png" width=
"48" height=
"48" alt=
"" style=
"border:none; vertical-align:top" /> </a><a href=
"https://bitbucket.org/OPiMedia/alphanormalize_php"><tt>alphanormalize_php</tt></a> – tests</h1>
102 <div
class=
"smallskip center">
103 <a rel=
"nofollow" lang=
"fr" href=
"http://www.opimedia.be/" style=
"text-decoration:none"><img src=
"http://www.opimedia.be/_png/OPi.png" width=
"41" height=
"34" alt=
"" style=
"border:none; vertical-align:middle" /> </a><a lang=
"fr" href=
"http://www.opimedia.be/">Olivier <span
class=
"surname">Pirson</span></a>
105 <a
class=
"mail" href=
"mailto:olivier.pirson.opi@gmail.com?subject=[alphanormalize_php]"><tt>olivier.pirson.opi@gmail.com</tt></a>
109 <div
class=
"smallskip center">
113 <li>Sources on Bitbucket: <a href=
"https://bitbucket.org/OPiMedia/alphanormalize_php"><tt>https:
114 <li><a href=
"http://www.opimedia.be/DS/webdev/PHP/alphanormalize-php/docs/">Online HTML documentation</a></li>
115 <li><a href=
"http://www.opimedia.be/DS/webdev/PHP/alphanormalize-php/alphanormalize-test.php">Online simple test page</a></li>
118 <div
class=
"bigskip">
121 $s =
'<pre>Il était une fois… des <em>caractères</em> "bizarroïdes" (avec accent, cédille et compagnie, ou α, β, etc.) 122 accompagnés ou pas de formatage <em>(X)HTML</em>. 123 Je cherchais à m’en débarrasser ! 124 Ceci est ma solution.</pre>';
130 <td
class=
"sep"></td>
131 <td><?php echo
$s; ?></td>
136 <td
class=
"sep"></td>
141 <td
class=
"sep"></td>
146 <th>htmlspecialchars(
$s)</th>
147 <td
class=
"sep"></td>
148 <td><?php echo htmlspecialchars(
$s); ?></td>
152 <td
class=
"sep"></td>
157 <td
class=
"sep"></td>
168 require
'accentalpha_to_alpha.inc';
175 if (in_array($c, array(
'À',
'ß',
'à',
'Œ'),
true)) {
176 echo
'<td class="sep"></td> 180 echo
'<td>', $c,
'</td> 186 <th>$ACCENTALPHA_TO_ALPHA[$c]</th> 190 if (in_array($c, array(
'À',
'ß',
'à',
'Œ'),
true)) {
191 echo
'<td class="sep"></td> 195 echo
'<td>', $v,
'</td> 208 (Adopts the standard <acronym>ONU</acronym>/<acronym>ELOT</acronym>:
209 see. <i>Memento <a href=
"http://www.opimedia.be/DS/mementos/grecs.htm">grecs</a></i>):
213 require
'greek_to_alpha.inc';
220 if (in_array($c, array(
'Α',
'α',
'ς',
'σ',
'ϑ'),
true)) {
221 echo
'<td class="sep"></td> 225 echo
'<td>', $c,
'</td> 231 <th>$GREEK_TO_ALPHA[$c]</th> 235 if (in_array($c, array(
'Α',
'α',
'ς',
'σ',
'ϑ'),
true)) {
236 echo
'<td class="sep"></td> 240 echo
'<td>', $v,
'</td> 251 <div
class=
"bigbigbigskip">
252 Associative table returned by the PHP
function 253 <tt>get_html_translation_table(HTML_SPECIALCHARS)</tt>:
258 <th>htmlspecialchars($c)</th> 259 <td class="sep"></td> 262 foreach (get_html_translation_table(HTML_SPECIALCHARS) as $c=>$v) {
263 echo
'<td>', htmlspecialchars($c),
'</td> 269 <th>htmlspecialchars(get_html_translation_table(HTML_SPECIALCHARS)[$c])</th> 270 <td class="sep"></td> 273 foreach (get_html_translation_table(HTML_SPECIALCHARS) as $c=>$v) {
274 echo
'<td>', htmlspecialchars($v),
'</td> 280 <th>mb_str_alphanormalize($c)</th> 281 <td class="sep"></td> 284 foreach (get_html_translation_table(HTML_SPECIALCHARS) as $c=>$v) {
297 Associative table returned by the PHP
function 298 <tt>get_html_translation_table(HTML_ENTITIES)</tt>:
303 <th>htmlspecialchars(utf8_encode($c))</th> 304 <td class="sep"></td> 307 foreach (get_html_translation_table(HTML_ENTITIES) as $c=>$v) {
309 $c = utf8_encode($c);
313 :
' class="red">'), htmlspecialchars($c),
'</td> 319 <th>htmlspecialchars(get_html_translation_table(HTML_ENTITIES)[$c])</th> 320 <td class="sep"></td> 323 foreach (get_html_translation_table(HTML_ENTITIES) as $c=>$v) {
325 $c = utf8_encode($c);
329 :
' class="red">'), htmlspecialchars($v),
'</td> 335 <th>mb_str_alphanormalize(utf8_encode($c))</th> 336 <td class="sep"></td> 339 foreach (get_html_translation_table(HTML_ENTITIES) as $c=>$v) {
341 $c = utf8_encode($c);
354 (<?php echo count(get_html_translation_table(HTML_ENTITIES)); ?> éléments)
357 <div
class=
"bigbigbigskip">
358 Three associative tables (copied from Python dictionary of module
359 <a href=
"http://docs.python.org/py3k/library/html.entities.html#module-html.entities"><tt>html.entities</tt></a>):<br />
368 <td class="sep"></td> 373 $v = utf8_decode($v);
378 :
' class="green">'), $k,
'</td> 384 <th>htmlspecialchars($HTML_ENTITIES_ENTITYDEFS[$k])</th> 385 <td class="sep"></td> 399 :
' class="green">'), htmlspecialchars($v),
'</td> 408 (In <span
class=
"green">green</span> the <?php echo $nb_diff; ?> items over <?php echo count($HTML_ENTITIES_ENTITYDEFS); ?>
409 which are not in <tt>get_html_translation_table(HTML_ENTITIES)</tt>.
410 Previous PHP 5.4, all HTML entities are not supported!)
420 <td class="sep"></td> 426 $c = utf8_decode($c);
431 :
' class="green">'), $k,
'</td> 437 <th>$HTML_ENTITIES_NAME2CODEPOINT[$k]</th> 438 <td class="sep"></td> 444 $c = utf8_decode($c);
449 :
' class="green">'), $v,
'</td> 467 <td class="sep"></td> 472 echo
'<td class="sep"></td> 478 $c = utf8_decode($c);
483 :
' class="green">'), $k,
'</td> 489 <th>$HTML_ENTITIES_CODEPOINT2NAME[$k]</th> 490 <td class="sep"></td> 495 echo
'<td class="sep"></td> 501 $c = utf8_decode($c);
506 :
' class="green">'), $v,
'</td> 520 foreach (get_html_translation_table(HTML_ENTITIES) as $c=>$v) {
522 $c = utf8_encode($c);
524 $v = mb_substr($v, 1, mb_strlen($v) - 2);
mb_str_accentalpha_to_alpha($s, $encoding=null)
Copy of $s without "accents".
mb_str_greek_to_alpha($s, $encoding=null)
Copy of $s with the characters of the Greek alphabet were replaced.
$HTML_ENTITIES_CODEPOINT2NAME
version()
Return the version of this module.
$array_get_html_translation_table
$HTML_ENTITIES_ENTITYDEFS
mb_str_alphanormalize($s, $strip=false, $entity_decode=false, $replacement='_', $encoding=null)
Copy of $s without "accents" with the characters of the Greek alphabet were replaced and all non-alph...
$HTML_ENTITIES_NAME2CODEPOINT