本文整理汇总了PHP中Encoding::convert_to_utf8方法的典型用法代码示例。如果您正苦于以下问题:PHP Encoding::convert_to_utf8方法的具体用法?PHP Encoding::convert_to_utf8怎么用?PHP Encoding::convert_to_utf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::convert_to_utf8方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read_object
/**
* Read the next object from the resource. In this case, the 'row' is the
* row in the csv file, and 'line' returns the line number in the file that
* the object STARTED on. (CSV objects may span multiple lines, if they
* contain newlines).
*
* @return array|false
*/
protected function read_object()
{
$obj = fgetcsv($this->csv_fp, null, $this->csv_delim, $this->csv_encl);
$num = $this->line_num;
if (!$obj) {
return false;
} else {
// optionally remove the last, probably blank, column
if (count($obj) && $this->lastcol_skip) {
array_pop($obj);
}
// Increment line number, including any newlines in the object.
// Also check for UTF-8 encoding
$this->line_num++;
foreach ($obj as $i => $col) {
$this->line_num += substr_count($col, "\n");
if (!Encoding::is_utf8($col)) {
$obj[$i] = Encoding::convert_to_utf8($col);
}
}
return array('row' => $this->position + ($this->csv_skip ? 2 : 1), 'data' => $obj, 'line' => $num);
}
}
示例2: air2_str_clean
/**
* Trim, utf8-ify and normalize-newlines for a string.
*
* @param string $str
* @return string
*/
function air2_str_clean($str)
{
if (is_null($str) || !is_string($str) || strlen($str) == 0) {
return $str;
}
// UTF8-ify
$str = Encoding::convert_to_utf8($str);
// normalize newlines
$str = air2_normalize_newlines($str);
// trim
$str = trim($str);
return $str;
}
示例3: array
*/
$post_params = array();
// ensure all values are UTF8
foreach ($_POST as $key => $value) {
// skip some special key names
if (substr($key, 0, 6) == "X-PIN-") {
continue;
}
if (is_array($value)) {
$utf8ified = array();
foreach ($value as $item) {
$utf8ified[] = Encoding::convert_to_utf8($item);
}
$value = $utf8ified;
} else {
$value = Encoding::convert_to_utf8($value);
}
$post_params[$key] = $value;
}
// handle any files
$upload_error = false;
if ($_FILES) {
foreach ($_FILES as $key => $file) {
if (isset($file['error']) && $file['error'] === UPLOAD_ERR_NO_FILE) {
$post_params[$key] = false;
continue;
// silently skip it
}
//Carper::carp(var_export($file,true));
if ($file['error'] !== UPLOAD_ERR_OK) {
$err = new UploadException($file['error']);