/** * @param string $html_ * @param \Components\Io_Charset $charset_ * * @return \Components\Text_Html_Tidy */ public static function tidy($html_, Io_Charset $charset_ = null) { if (null === $charset_) { $charset_ = Io_Charset::UTF_8(); } return new Text_Html_Tidy($html_, $charset_); }
public function __construct($value_, Io_Charset $charset_ = null) { if (null === $charset_) { $charset_ = Io_Charset::UTF_8(); } $this->m_value = $value_; $this->m_charset = $charset_; }
/** * @return \Components\Io_Mimetype */ public function getMimetype() { if (null === $this->m_mimeType) { if (!($this->m_mimeType = Io_Mimetype::forFileName($this->m_uri->getPath()))) { $this->m_mimeType = Io_Mimetype::TEXT_HTML(Io_Charset::UTF_8()); } } return $this->m_mimeType; }
/** * @return \Components\Mail_Part_Text */ public static function utf8($content_) { return new self($content_, Io_Charset::UTF_8()); }
/** * @return \Components\Io_Charset */ public function charset() { if (null === $this->m_charset) { $this->m_charset = Io_Charset::forName(self::$m_charsets[$this->m_name]); } return $this->m_charset; }
/** * @param string $filename_ * * @return \Components\Io_Charset */ public static function charset($filename_) { return Io_Charset::forFilePath($filename_); }
/** * @see \xml\escape() escape */ public static function escapeXml($string_, Io_Charset $charset_ = null, $flags_ = ENT_QUOTES) { if (null === $charset_) { return \xml\escape($string_, null, ENT_XML1, $flags_); } return \xml\escape($string_, $charset_->name(), ENT_XML1, $flags_); }
public function setBarcode($text_, $alternativeText_ = null, Io_Charset $charset_ = null, $type_ = self::TYPE_BARCODE_2DMATRIX_QR) { if (null === $charset_) { $charset_ = Io_Charset::ISO_8859_1(); } $barcode = array('format' => $type_, 'message' => $text_, 'messageEncoding' => strtolower($charset_->name())); if (null !== $alternativeText_) { $barcode['altText'] = $alternativeText_; } $this->properties->barcode = $barcode; }
/** * @param string $unicode_ * @param \Components\Io_Charset $charset_ * * @return string */ public function unicodeDecode($unicode_, Io_Charset $charset_ = null) { if (null === $charset_) { $charset_ = Io_Charset::UTF_16_BE(); } self::$m_convertImplTo = $this; self::$m_convertImplFrom = $charset_; return preg_replace_callback('/(?:\\\\u[0-9a-fA-Z]{4})+/', function ($string_) { return Io_Charset::__unicodeDecodeConvertEncodingImpl(pack('H*', strtr($string_[0], ['\\u' => '']))); }, $unicode_); }
/** * @param string $file_ * * @return \Components\Io_Mimetype */ public static function forFilePath($file_, Io_Charset $charset_ = null) { $info = null; if ($finfo = @finfo_open(FILEINFO_MIME)) { $info = @finfo_file($finfo, $file_); @finfo_close($finfo); } if (false === $info) { return self::forFileName($file_); } $mimetype = trim(substr($info, 0, strpos($info, ';'))); /** * finfo seems to return text/plain for most text files.. * I think we can achive more accurate information by relying on the * file extension, since there should be no real danger as soon as we * are sure its really a text file. */ if (0 === strpos($mimetype, 'text')) { return static::forFileName($file_); } if (isset(self::$m_mapMimetypes[$mimetype])) { $name = self::$m_mapMimetypes[$mimetype]; } else { $name = self::$m_mapMimetypes[self::APPLICATION_OCTET_STREAM]; } if (null === $charset_) { $charset = trim(substr($info, strpos($info, ';') + 1)); return static::$name(Io_Charset::forName($charset)); } return static::$name($charset_); }
/** * @return \Components\Mail */ public static function utf8() { return new self(Io_Charset::UTF_8()); }
/** * @return \Components\Io_Charset */ public function getCharset() { if ($mimeType = $this->getMimetype()) { return $mimeType->charset(); } return Io_Charset::defaultCharset(); }