| | |
| | | var $width = 70; |
| | | |
| | | /** |
| | | * Target character encoding for output text |
| | | * |
| | | * @var string $charset |
| | | * @access public |
| | | */ |
| | | var $charset = 'UTF-8'; |
| | | |
| | | /** |
| | | * List of preg* regular expression patterns to search for, |
| | | * used in conjunction with $replace. |
| | | * |
| | |
| | | * @access public |
| | | * @return void |
| | | */ |
| | | function html2text( $source = '', $from_file = false, $do_links = true, $width = 75 ) |
| | | function html2text( $source = '', $from_file = false, $do_links = true, $width = 75, $charset = 'UTF-8' ) |
| | | { |
| | | if ( !empty($source) ) { |
| | | $this->set_html($source, $from_file); |
| | |
| | | $this->set_base_url(); |
| | | $this->_do_links = $do_links; |
| | | $this->width = $width; |
| | | $this->charset = $charset; |
| | | } |
| | | |
| | | /** |
| | |
| | | $text = preg_replace($this->ent_search, $this->ent_replace, $text); |
| | | |
| | | // Replace known html entities |
| | | $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8'); |
| | | $text = html_entity_decode($text, ENT_QUOTES, $this->charset); |
| | | |
| | | // Remove unknown/unhandled entities (this cannot be done in search-and-replace block) |
| | | $text = preg_replace('/&([a-zA-Z0-9]{2,6}|#[0-9]{2,4});/', '', $text); |
| | |
| | | */ |
| | | private function _strtoupper($str) |
| | | { |
| | | $str = html_entity_decode($str, ENT_COMPAT, RCMAIL_CHARSET); |
| | | $str = html_entity_decode($str, ENT_COMPAT, $this->charset); |
| | | |
| | | if (function_exists('mb_strtoupper')) |
| | | $str = mb_strtoupper($str); |
| | | else |
| | | $str = strtoupper($str); |
| | | |
| | | $str = htmlspecialchars($str, ENT_COMPAT, RCMAIL_CHARSET); |
| | | $str = htmlspecialchars($str, ENT_COMPAT, $this->charset); |
| | | |
| | | return $str; |
| | | } |