当前位置: 首页>>代码示例>>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;未经允许,请勿转载。