protected function encode($str) {
		if (empty($str) || $this->charset == 'UTF-8')
			return $str;
		if (extension_loaded('iconv'))
			$out = @iconv("UTF-8", $this->charset."//IGNORE", $str);
		if (!isset($out) || !$out)
			$out = extension_loaded('mbstring')
				? mb_convert_encoding($str,$this->charset,"UTF-8")
				: utf8_decode($str);
		return $out ?: $str;
	}