ILIAS
eassessment Revision 61809
◀ ilDoc Overview
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Groups
Pages
supported_chars.php
Go to the documentation of this file.
1
<?php
2
4
function
match_aliases
($str) {
5
if
(!preg_match_all(
'/Alias:\s*(\S+)/S'
, $str, $matches) ||
6
$matches[1][0] ==
'None'
) {
7
return
array();
8
}
9
10
return
$matches[1];
11
12
}
13
14
16
function
test_charset
($charset) {
17
return
(
bool
) @iconv($charset,
'UTF-8'
,
'a'
);
18
}
19
20
21
22
$file
= file_get_contents(
'http://www.iana.org/assignments/character-sets'
);
23
24
preg_match_all(
'/Name:\s*(\S+).*[\r\n]+MIBenum:.*[\r\n]+Source:.*[\r\n]+((?:Alias:\s*\S+.*[\r\n]+)*)/'
,
$file
,
$charsets
);
25
26
array_shift(
$charsets
);
27
$charsets
[1] = array_map(
'match_aliases'
,
$charsets
[1]);
28
usort(
$charsets
[0],
'strnatcasecmp'
);
29
30
$total
= count(
$charsets
[0]);
31
$total_alias
= count(
$charsets
[1]);
32
$ok
= 0;
33
$aliases
= 0;
34
35
for
($i = 0; $i <
$total
; $i++) {
36
37
echo
$charsets
[0][$i] .
': '
;
38
39
if
(
test_charset
(
$charsets
[0][$i])) {
40
++
$ok
;
41
$valid
[] =
$charsets
[0][$i];
42
echo
"true"
;
43
$a = array();
44
45
foreach
(
$charsets
[1][$i] as $alias) {
46
if
(
test_charset
($alias)) {
47
++
$aliases
;
48
$a[] = $alias;
49
}
50
}
51
52
if
($a = join($a,
', '
))
53
echo
"; Valid aliases: $a"
;
54
55
echo
"\n"
;
56
57
}
else
{
58
echo
"false\n"
;
59
}
60
}
61
62
echo
"\n\n"
;
63
print_r(
$valid
);
64
echo
"\n\n"
;
65
66
echo number_format(
$ok
* 100 / $total, 2,
','
,
'.'
) .
"% of good charsets\n"
;
67
echo number_format(
$aliases
* 100 /
$total_alias
, 2,
','
,
'.'
) .
"% of good aliases\n"
;
68
echo
"$total charsets\n"
;
69
70
?>
Services
XHTMLValidator
validator
supported_chars.php
Generated on Mon Apr 25 2016 19:01:46 for ILIAS by
1.8.1.2 (using
Doxyfile
)