*/ class Utf8Decoder extends Converter { protected $started = false; protected $to_encoding; protected $encoding_converter; function __construct($to_encoding = null) { $this->to_encoding = $to_encoding ? $to_encoding : Encoding::system(); $this->encoding_converter = EncodingConverter::create(Utf8::NAME, $this->to_encoding); $this->reset(); } function from_encoding() { return Utf8::NAME; } function to_encoding() { return $this->to_encoding; } function reset() { $this->started = false; } function convert($string) { if (!$this->started) { $this->started = true; $string = Utf8::instance()->trim($string); return $this->encoding_converter->convert($string); } else { return $this->encoding_converter->convert($string); } return $string; } }