tests: blacklist sqlite3_str and sqlite3_win32 functions
[m6w6/ext-psi] / tests / iconv / iconv002.phpt
1 --TEST--
2 iconv abstraction
3 --INI--
4 psi.directory={PWD}/../../psi.d:{PWD}
5 --SKIPIF--
6 <?php
7 extension_loaded("psi") or die("skip - need ext/psi");
8 function_exists("psi\\iconv_open") or die("skip - need iconv");
9 ?>
10 --FILE--
11 ===TEST===
12 <?php
13
14 class iconv_stream {
15 private $cd;
16
17 function __construct($from, $to) {
18 if (!$this->cd = psi\iconv_open($to, $from)) {
19 throw new Exception(psi\strerror(psi\errno()));
20 }
21 }
22
23 function __destruct() {
24 psi\iconv_close($this->cd);
25 }
26
27 function update(string $data) : string {
28 if (0 > psi\iconv($this->cd, $data, $result)) {
29 throw new Exception(psi\strerror(psi\errno()));
30 }
31 return $result;
32 }
33 }
34
35 $ic = new iconv_stream("utf8", "latin1");
36
37 foreach (["föö", "bää", "baßß"] as $str) {
38 var_dump(array_map("ord", str_split($ic->update($str))));
39 }
40
41 $bc = new iconv_stream("latin1", "utf8");
42 foreach (["föö", "bää", "baßß"] as $str) {
43 var_dump($bc->update($ic->update($str)));
44 }
45
46 ?>
47 ===DONE===
48 --EXPECT--
49 ===TEST===
50 array(3) {
51 [0]=>
52 int(102)
53 [1]=>
54 int(246)
55 [2]=>
56 int(246)
57 }
58 array(3) {
59 [0]=>
60 int(98)
61 [1]=>
62 int(228)
63 [2]=>
64 int(228)
65 }
66 array(4) {
67 [0]=>
68 int(98)
69 [1]=>
70 int(97)
71 [2]=>
72 int(223)
73 [3]=>
74 int(223)
75 }
76 string(5) "föö"
77 string(5) "bää"
78 string(6) "baßß"
79 ===DONE===