当前位置: 首页>>代码示例>>PHP>>正文


PHP Encoding类代码示例

本文整理汇总了PHP中Encoding的典型用法代码示例。如果您正苦于以下问题:PHP Encoding类的具体用法?PHP Encoding怎么用?PHP Encoding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Encoding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct($from_encoding = null, $convert_html_entities = false)
 {
     $this->from_encoding = $from_encoding ? $from_encoding : Encoding::system();
     $this->encoding_converter = EncodingConverter::create($this->from_encoding, Utf8::NAME);
     $this->convert_html_entities = $convert_html_entities;
     $this->reset();
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:7,代码来源:utf8_encoder.class.php

示例2: getCustomArray

function getCustomArray($_getCustomParams = null)
{
    Server::InitDataBlock(array("INPUTS"));
    if (empty($_getCustomParams)) {
        $_getCustomParams = array('', '', '', '', '', '', '', '', '', '');
    }
    for ($i = 0; $i <= 9; $i++) {
        if (isset($_GET["cf" . $i])) {
            $_getCustomParams[$i] = Encoding::Base64UrlDecode($_GET["cf" . $i]);
        } else {
            if (isset($_POST["p_cf" . $i]) && !empty($_POST["p_cf" . $i])) {
                $_getCustomParams[$i] = Encoding::Base64UrlDecode($_POST["p_cf" . $i]);
            } else {
                if (isset($_POST["form_" . $i]) && !empty($_POST["form_" . $i])) {
                    $_getCustomParams[$i] = $_POST["form_" . $i];
                } else {
                    if ((Server::$Inputs[$i]->Type == "CheckBox" || Server::$Inputs[$i]->Type == "ComboBox") && empty($_getCustomParams[$i])) {
                        $_getCustomParams[$i] = "0";
                    }
                }
            }
        }
    }
    return $_getCustomParams;
}
开发者ID:sgh1986915,项目名称:laravel-eyerideonline,代码行数:25,代码来源:functions.global.inc.php

示例3: testRemoveNonPrintableAsciiChars

 public function testRemoveNonPrintableAsciiChars()
 {
     $stringWithAllAsciiChars = "";
     for ($i = 0; $i < 256; $i++) {
         $stringWithAllAsciiChars .= chr($i);
     }
     $stringWithOnlyPrintableChars = Encoding::toPrintableAscii($stringWithAllAsciiChars);
     $this->assertEquals(224, strlen($stringWithOnlyPrintableChars));
 }
开发者ID:no-chris,项目名称:connector,代码行数:9,代码来源:EncodingTest.php

示例4: encoding

 public function encoding($text)
 {
     // encoding para ISO 8859-1
     return $text;
     if (strrpos(Run::ENCODING, "utf") != "") {
         return Encoding::toUTF8($text);
     } else {
         return Encoding::toLatin1($text);
     }
 }
开发者ID:obscurun,项目名称:run-dev,代码行数:10,代码来源:string.php

示例5: execute

 public function execute($sqlQuery, $sqlParams)
 {
     if (empty($sqlQuery)) {
         throw new \InvalidArgumentException("sqlQuery should not be empty");
     }
     if (!is_array($sqlParams)) {
         throw new \InvalidArgumentException("sqlParams should be an array");
     }
     $this->sqlQuery = $sqlQuery;
     $this->sqlParams = Encoding::toUtf8($sqlParams);
     return $this->prepareAndRun();
 }
开发者ID:no-chris,项目名称:connector,代码行数:12,代码来源:Db.php

示例6: toSlug

 static function toSlug($string, $space = "-")
 {
     $string = Encoding::fixUTF8(Encoding::toUTF8($string));
     $string = self::mb_strtolower(self::mb_trim($string));
     $string = self::cleanTextHtml($string);
     if (function_exists('iconv')) {
         $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
     }
     $string = preg_replace('/[^a-z0-9 _.-]/', '', $string);
     $string = preg_replace('/[\\s\\-_]+/', $space, $string);
     $string = str_replace(' ', $space, $string);
     return $string;
 }
开发者ID:sostenesgomes,项目名称:middleware-vtex,代码行数:13,代码来源:Strings_UTF8.php

示例7: __construct

 public function __construct()
 {
     $this->setAutomaticInstallation(true);
     $this->setUpdatePlan(new LogUpdatePlan());
     $this->setDataBackendContainer(new FileDataBackendContainer());
     $encoding = null;
     try {
         $encoding = Encoding::getInstance("UTF-8");
     } catch (UnsupportedEncodingException $e) {
         trigger_error("UTF-8 is not supported; bav is falling back to ISO-8859-15", E_WARNING);
         $encoding = Encoding::getInstance("ISO-8859-15");
     }
     $this->setEncoding($encoding);
 }
开发者ID:bmdevel,项目名称:bav,代码行数:14,代码来源:DefaultConfiguration.php

示例8: getAll

 public function getAll()
 {
     $this->csvArray = array();
     $isHeaderLine = true;
     while (($csvLine = fgets($this->csvFile)) !== false) {
         $csvLineArray = $this->splitCsvLine($csvLine);
         if ($isHeaderLine) {
             $this->setColumnsNames($csvLineArray);
             $isHeaderLine = false;
         } else {
             $this->csvArray[] = $this->mapCsvLineToObject($csvLineArray);
         }
     }
     fclose($this->csvFile);
     return Encoding::toUtf8($this->csvArray);
 }
开发者ID:no-chris,项目名称:connector,代码行数:16,代码来源:CsvFile.php

示例9: testEncode

 /**
  * Tests the encode() method.
  *
  * @see \Jyxo\Mail\Encoding::encode()
  */
 public function testEncode()
 {
     $data = file_get_contents($this->filePath . '/email.html');
     foreach ($this->encodings as $encoding) {
         $encoded = Encoding::encode($data, $encoding, 75, "\n");
         $this->assertStringEqualsFile($this->filePath . '/encoding-' . $encoding . '.txt', $encoded);
     }
     try {
         Encoding::encode('data', 'dummy-encoding', 75, "\n");
         $this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class));
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (\Exception $e) {
         // Correctly thrown exception
         $this->assertInstanceOf(\InvalidArgumentException::class, $e);
     }
 }
开发者ID:jyxo,项目名称:php,代码行数:22,代码来源:EncodingTest.php

示例10: detect_encoding

 /**
  * Returns the file encoding
  * 
  * @return Encoding
  */
 static function detect_encoding($path)
 {
     $abstract = array();
     // We assume that 200 lines are enough for encoding detection.
     // here we must get at the raw data so we don't use other functions
     // it's not possible to read x chars as this would not be safe with utf
     // (chars may be split in the middle)
     $handle = fopen($path, 'r');
     $i = 0;
     while (($line = fgets($handle)) !== false && $i < 200) {
         $i++;
         $abstract[] = $line;
     }
     fclose($handle);
     $abstract = implode($abstract);
     return Encoding::detect_encoding($abstract);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:22,代码来源:file_reader.class.php

示例11: cumulus_update

 function cumulus_update($file)
 {
     $infile = fopen($file, 'r');
     $firstLine = fgetcsv($infile);
     $csvArray = array();
     while (!feof($infile)) {
         $assoc = array();
         $line = fgetcsv($infile);
         if ($line[0]) {
             foreach ($line as $index => $value) {
                 $assoc[$firstLine[$index]] = $value ? Encoding::toUTF8($value) : NULL;
             }
             $csvArray[] = $assoc;
         }
     }
     fclose($infile);
     print_r($csvArray);
 }
开发者ID:rbgvictoria,项目名称:vicflora,代码行数:18,代码来源:roboflow_helper.php

示例12: decompress

 /**
  * Decompression of deflated string.
  *
  * Will attempt to decompress using the RFC 1950 standard, and if that fails
  * then the RFC 1951 standard deflate will be attempted. Finally, the RFC
  * 1952 standard gzip decode will be attempted. If all fail, then the
  * original compressed string will be returned.
  *
  * @since 2.8
  *
  * @param string  $compressed String to decompress.
  * @param int     $length     The optional length of the compressed data.
  * @return string|bool False on failure.
  */
 public static function decompress($compressed, $length = null)
 {
     if (empty($compressed)) {
         return $compressed;
     }
     if (false !== ($decompressed = @gzinflate($compressed))) {
         return $decompressed;
     }
     if (false !== ($decompressed = Encoding::compatible_gzinflate($compressed))) {
         return $decompressed;
     }
     if (false !== ($decompressed = @gzuncompress($compressed))) {
         return $decompressed;
     }
     if (function_exists('gzdecode')) {
         $decompressed = @gzdecode($compressed);
         if (false !== $decompressed) {
             return $decompressed;
         }
     }
     return $compressed;
 }
开发者ID:pcbrsites,项目名称:leeflets,代码行数:36,代码来源:encoding.php

示例13: encoder

 /**
  *
  * @param type $from
  * @return Utf8Encoder
  */
 public function encoder($from = null)
 {
     $from = $from ? $from : Encoding::system();
     return new Utf8Encoder($from);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:10,代码来源:utf8.class.php

示例14: 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;
}
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:19,代码来源:AIR2_Utils.php

示例15: str_replace

            if (!empty($groupid) && isset(Server::$Groups[$groupid])) {
                $html = str_replace("<!--SM_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[0]) ? "none" : "", $html);
                $html = str_replace("<!--SO_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[1]) ? "none" : "", $html);
                $html = str_replace("<!--PR_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[2]) ? "none" : "", $html);
                $html = str_replace("<!--FV_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[4]) ? "none" : "", $html);
                $html = str_replace("<!--FU_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[5]) || !empty($_GET[GET_EXTERN_DYNAMIC_GROUP]) ? "none" : "", $html);
                $html = str_replace("<!--post_chat_js-->", base64_encode(Server::$Groups[$groupid]->PostJS), $html);
            }
            $html = str_replace("<!--TR_HIDDEN-->", strlen(Server::$Configuration->File["gl_otrs"]) > 1 ? "" : "none", $html);
            $html = str_replace("<!--ET_HIDDEN-->", !empty(Server::$Configuration->File["gl_retr"]) && !empty(Server::$Configuration->File["gl_soct"]) ? "" : "none", $html);
        }
    }
}
$header = IOStruct::GetFile(PATH_TEMPLATES . "header.tpl");
if (isset($_GET[GET_EXTERN_USER_HEADER]) && !empty($_GET[GET_EXTERN_USER_HEADER])) {
    $header = str_replace("<!--logo-->", "<img src=\"" . Encoding::Base64UrlDecode($_GET[GET_EXTERN_USER_HEADER]) . "\" border=\"0\"><br>", $header);
} else {
    if (!empty(Server::$Configuration->File["gl_cali"])) {
        $header = str_replace("<!--logo-->", "<img src=\"" . Server::$Configuration->File["gl_cali"] . "\" border=\"0\"><br>", $header);
    }
}
if (!empty(Server::$Configuration->File["gl_cahi"])) {
    $header = str_replace("<!--background-->", "<img src=\"" . Server::$Configuration->File["gl_cahi"] . "\" border=\"0\"><br>", $header);
}
$html = str_replace("<!--param-->", @Server::$Configuration->File["gl_cpar"], $html);
$html = str_replace("<!--header-->", $header, $html);
$html = str_replace("<!--server-->", LIVEZILLA_URL, $html);
$html = str_replace("<!--html-->", "<html dir=\"" . LocalizationManager::$Direction . "\">", $html);
$html = str_replace("<!--rtl-->", To::BoolString(LocalizationManager::$Direction == "rtl"), $html);
$html = str_replace("<!--dir-->", LocalizationManager::$Direction, $html);
$html = str_replace("<!--url_get_params-->", getParams(), $html);
开发者ID:sgh1986915,项目名称:laravel-eyerideonline,代码行数:31,代码来源:chat.php


注:本文中的Encoding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。