4 psi.directory={PWD}/../../psi.d:{PWD}
7 extension_loaded("psi") or die("skip - need ext/psi");
8 function_exists("psi\\iconv_open") or die("skip - need iconv");
17 function __construct($from, $to) {
18 if (!$this->cd = psi\iconv_open($to, $from)) {
19 throw new Exception(psi\strerror(psi\errno()));
23 function __destruct() {
24 psi\iconv_close($this->cd);
27 function update(string $data) : string {
28 if (0 > psi\iconv($this->cd, $data, $result)) {
29 throw new Exception(psi\strerror(psi\errno()));
35 $ic = new iconv_stream("utf8", "latin1");
37 foreach (["föö", "bää", "baßß"] as $str) {
38 var_dump(array_map("ord", str_split($ic->update($str))));
41 $bc = new iconv_stream("latin1", "utf8");
42 foreach (["föö", "bää", "baßß"] as $str) {
43 var_dump($bc->update($ic->update($str)));