Initial commit
[moodle.git] / search / Zend / Search / Lucene / EncodingConverter.php
CommitLineData
682d4032 1<?php
2
3class EncodingConverter {
4 private $last_error,
5 $in_encoding,
6 $out_encoding;
7
8 function __construct($in_encoding, $out_encoding) {
9 $this->in_encoding = $in_encoding;
10 $this->out_encoding = $out_encoding;
11 } //constructor
12
13 function handleError($err, $msg) {
14 $this->last_error = $msg;
15 } //handleError
16
17 function convert($str) {
18 $this->last_error = FALSE;
19
20 set_error_handler(array(&$this, 'handleError'));
21 $ret = iconv($this->in_encoding, $this->out_encoding, $str);
22 restore_error_handler();
23
24 return $ret;
25 } //convert
26
27 function getLastError() {
28 return $this->last_error;
29 } //getLastError
30} //EncodingConverter
31
32?>