當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rcube_charset::detect方法代碼示例

本文整理匯總了PHP中rcube_charset::detect方法的典型用法代碼示例。如果您正苦於以下問題:PHP rcube_charset::detect方法的具體用法?PHP rcube_charset::detect怎麽用?PHP rcube_charset::detect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rcube_charset的用法示例。


在下文中一共展示了rcube_charset::detect方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import

 /**
  *
  */
 public function import($csv)
 {
     // convert to UTF-8
     $head = substr($csv, 0, 4096);
     $fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1');
     // fallback to Latin-1?
     $charset = rcube_charset::detect($head, RCUBE_CHARSET);
     $csv = rcube_charset::convert($csv, $charset);
     $head = '';
     $this->map = array();
     // Parse file
     foreach (preg_split("/[\r\n]+/", $csv) as $i => $line) {
         $elements = $this->parse_line($line);
         if (empty($elements)) {
             continue;
         }
         // Parse header
         if (empty($this->map)) {
             $this->parse_header($elements);
             if (empty($this->map)) {
                 break;
             }
         } else {
             $this->csv_to_vcard($elements);
         }
     }
 }
開發者ID:CDN-Sparks,項目名稱:owncloud,代碼行數:30,代碼來源:rcube_csv2vcard.php

示例2: import

 /**
  *
  */
 public function import($csv)
 {
     // convert to UTF-8
     $head = substr($csv, 0, 4096);
     $charset = rcube_charset::detect($head, RCUBE_CHARSET);
     $csv = rcube_charset::convert($csv, $charset);
     $head = '';
     $this->map = array();
     // Parse file
     foreach (preg_split("/[\r\n]+/", $csv) as $line) {
         $elements = $this->parse_line($line);
         if (empty($elements)) {
             continue;
         }
         // Parse header
         if (empty($this->map)) {
             $this->parse_header($elements);
             if (empty($this->map)) {
                 break;
             }
         } else {
             $this->csv_to_vcard($elements);
         }
     }
 }
開發者ID:BIGGANI,項目名稱:zpanelx,代碼行數:28,代碼來源:rcube_csv2vcard.php

示例3: import

 /**
  *
  */
 public function import($csv)
 {
     // convert to UTF-8
     $head = substr($csv, 0, 4096);
     $charset = rcube_charset::detect($head, RCUBE_CHARSET);
     $csv = rcube_charset::convert($csv, $charset);
     $csv = preg_replace(array('/^[\\xFE\\xFF]{2}/', '/^\\xEF\\xBB\\xBF/', '/^\\x00+/'), '', $csv);
     // also remove BOM
     $head = '';
     $prev_line = false;
     $this->map = array();
     $this->gmail_map = array();
     // Parse file
     foreach (preg_split("/[\r\n]+/", $csv) as $line) {
         if (!empty($prev_line)) {
             $line = '"' . $line;
         }
         $elements = $this->parse_line($line);
         if (empty($elements)) {
             continue;
         }
         // Parse header
         if (empty($this->map)) {
             $this->parse_header($elements);
             if (empty($this->map)) {
                 break;
             }
         } else {
             // handle multiline elements (e.g. Gmail)
             if (!empty($prev_line)) {
                 $first = array_shift($elements);
                 if ($first[0] == '"') {
                     $prev_line[count($prev_line) - 1] = '"' . $prev_line[count($prev_line) - 1] . "\n" . substr($first, 1);
                 } else {
                     $prev_line[count($prev_line) - 1] .= "\n" . $first;
                 }
                 $elements = array_merge($prev_line, $elements);
             }
             $last_element = $elements[count($elements) - 1];
             if ($last_element[0] == '"') {
                 $elements[count($elements) - 1] = substr($last_element, 1);
                 $prev_line = $elements;
                 continue;
             }
             $this->csv_to_vcard($elements);
             $prev_line = false;
         }
     }
 }
開發者ID:yozhi,項目名稱:YetiForceCRM,代碼行數:52,代碼來源:rcube_csv2vcard.php

示例4: set_part_filename


//.........這裏部分代碼省略.........
                             $i++;
                         }
                     }
                 } else {
                     if (!empty($part->d_parameters['filename*0*'])) {
                         $i = 0;
                         while (isset($part->d_parameters['filename*' . $i . '*'])) {
                             $filename_encoded .= $part->d_parameters['filename*' . $i . '*'];
                             $i++;
                         }
                         if ($i < 2) {
                             if (!$headers) {
                                 $headers = $this->conn->fetchPartHeader($this->folder, $this->msg_uid, true, $part->mime_id);
                             }
                             $filename_encoded = '';
                             $i = 0;
                             $matches = array();
                             while (preg_match('/filename\\*' . $i . '\\*\\s*=\\s*"*([^"\\n;]+)[";]*/', $headers, $matches)) {
                                 $filename_encoded .= $matches[1];
                                 $i++;
                             }
                         }
                     } else {
                         if (!empty($part->ctype_parameters['name*0'])) {
                             $i = 0;
                             while (isset($part->ctype_parameters['name*' . $i])) {
                                 $filename_mime .= $part->ctype_parameters['name*' . $i];
                                 $i++;
                             }
                             if ($i < 2) {
                                 if (!$headers) {
                                     $headers = $this->conn->fetchPartHeader($this->folder, $this->msg_uid, true, $part->mime_id);
                                 }
                                 $filename_mime = '';
                                 $i = 0;
                                 $matches = array();
                                 while (preg_match('/\\s+name\\*' . $i . '\\s*=\\s*"*([^"\\n;]+)[";]*/', $headers, $matches)) {
                                     $filename_mime .= $matches[1];
                                     $i++;
                                 }
                             }
                         } else {
                             if (!empty($part->ctype_parameters['name*0*'])) {
                                 $i = 0;
                                 while (isset($part->ctype_parameters['name*' . $i . '*'])) {
                                     $filename_encoded .= $part->ctype_parameters['name*' . $i . '*'];
                                     $i++;
                                 }
                                 if ($i < 2) {
                                     if (!$headers) {
                                         $headers = $this->conn->fetchPartHeader($this->folder, $this->msg_uid, true, $part->mime_id);
                                     }
                                     $filename_encoded = '';
                                     $i = 0;
                                     $matches = array();
                                     while (preg_match('/\\s+name\\*' . $i . '\\*\\s*=\\s*"*([^"\\n;]+)[";]*/', $headers, $matches)) {
                                         $filename_encoded .= $matches[1];
                                         $i++;
                                     }
                                 }
                             } else {
                                 if (!empty($part->ctype_parameters['name'])) {
                                     $filename_mime = $part->ctype_parameters['name'];
                                 } else {
                                     if (!empty($part->headers['content-description'])) {
                                         $filename_mime = $part->headers['content-description'];
                                     } else {
                                         return;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // decode filename
     if (!empty($filename_mime)) {
         if (!empty($part->charset)) {
             $charset = $part->charset;
         } else {
             if (!empty($this->struct_charset)) {
                 $charset = $this->struct_charset;
             } else {
                 $charset = rcube_charset::detect($filename_mime, $this->default_charset);
             }
         }
         $part->filename = rcube_mime::decode_mime_string($filename_mime, $charset);
     } else {
         if (!empty($filename_encoded)) {
             // decode filename according to RFC 2231, Section 4
             if (preg_match("/^([^']*)'[^']*'(.*)\$/", $filename_encoded, $fmatches)) {
                 $filename_charset = $fmatches[1];
                 $filename_encoded = $fmatches[2];
             }
             $part->filename = rcube_charset::convert(urldecode($filename_encoded), $filename_charset);
         }
     }
 }
開發者ID:ehabqino,項目名稱:roundcubemail,代碼行數:101,代碼來源:rcube_imap.php

示例5: fix_attachment_name

 /**
  * Fix attachment name encoding if needed/possible
  */
 protected function fix_attachment_name($name, $part)
 {
     if ($name == rcube_charset::clean($name)) {
         return $name;
     }
     // find charset from part or its parent(s)
     if ($part->charset) {
         $charsets[] = $part->charset;
     } else {
         // check first part (common case)
         $n = strpos($part->mime_id, '.') ? preg_replace('/\\.[0-9]+$/', '', $part->mime_id) . '.1' : 1;
         if (($_part = $this->mime_parts[$n]) && $_part->charset) {
             $charsets[] = $_part->charset;
         }
         // check parents' charset
         $items = explode('.', $part->mime_id);
         for ($i = count($items) - 1; $i > 0; $i--) {
             $last = array_pop($items);
             $parent = $this->mime_parts[join('.', $items)];
             if ($parent && $parent->charset) {
                 $charsets[] = $parent->charset;
             }
         }
     }
     if ($this->headers->charset) {
         $charsets[] = $this->headers->charset;
     }
     if (empty($charsets)) {
         $rcube = rcube::get_instance();
         $charsets[] = rcube_charset::detect($name, $rcube->config->get('default_charset', RCUBE_CHARSET));
     }
     foreach (array_unique($charsets) as $charset) {
         $_name = rcube_charset::convert($name, $charset);
         if ($_name == rcube_charset::clean($_name)) {
             if (!$part->charset) {
                 $part->charset = $charset;
             }
             return $_name;
         }
     }
     return $name;
 }
開發者ID:Bergdahls,項目名稱:YetiForceCRM,代碼行數:45,代碼來源:rcube_message.php

示例6: detect_encoding

 /**
  * Returns UNICODE type based on BOM (Byte Order Mark)
  *
  * @param string Input string to test
  * @return string Detected encoding
  */
 private static function detect_encoding($string)
 {
     $fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1');
     // fallback to Latin-1
     return rcube_charset::detect($string, $fallback);
 }
開發者ID:rootsdigital,項目名稱:roundcubemail,代碼行數:12,代碼來源:rcube_vcard.php

示例7: rc_detect_encoding

function rc_detect_encoding($string, $failover = '')
{
    return rcube_charset::detect($string, $failover);
}
開發者ID:noikiy,項目名稱:roundcubemail,代碼行數:4,代碼來源:bc.php

示例8: test_detect

 /**
  * @dataProvider data_detect
  */
 function test_detect($input, $fallback, $output)
 {
     $this->assertEquals($output, rcube_charset::detect($input, $fallback));
 }
開發者ID:netcon-source,項目名稱:roundcubemail,代碼行數:7,代碼來源:Charset.php

示例9: rc_detect_encoding

function rc_detect_encoding($string, $failover = '')
{
    _deprecation_warning(__FUNCTION__);
    return rcube_charset::detect($string, $failover);
}
開發者ID:JotapePinheiro,項目名稱:roundcubemail,代碼行數:5,代碼來源:bc.php


注:本文中的rcube_charset::detect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。