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


PHP iconv函数代码示例

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


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

示例1: reParceCategoriesAction

 /**
  * @todo перенести в комманды
  * Контроллер для записи Категорий
  * @Secure(roles = "ROLE_ADMIN")
  * @Route("/testxmlcat", name = "testcategories")
  */
 public function reParceCategoriesAction()
 {
     $html = file_get_contents("http://www.medknigaservis.ru/ervr/medknigaservis.xml");
     $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
     $html = iconv("windows-1251", "utf-8", $html);
     $saw = new \nokogiri($html);
     $xml = $saw->get('category')->toArray();
     #echo '<pre>';
     #print_r($xml);
     #echo '</pre>';
     #echo '<hr />';
     for ($i = 0; true; $i++) {
         if (isset($xml[$i]['#text'][0])) {
             echo '<b>' . $xml[$i]['#text'][0] . '</b><br />';
             $cat = new MarketCategory();
             $cat->setName($xml[$i]['#text'][0]);
             $cat->setOfferId($xml[$i]['id']);
             $em = $this->getDoctrine()->getManager();
             $em->persist($cat);
             $em->flush();
         } else {
             break;
         }
     }
     return $this->render('EvrikaMainBundle:Shop:main.html.twig');
 }
开发者ID:Quiss,项目名称:Evrika,代码行数:32,代码来源:MarketController.php

示例2: addm

function addm($char, $mes, $priv)
{
    setlocale(LC_ALL, "ru_RU.CP1251");
    if (!isset($char['sex']) || $char['sex'] == "male") {
        $mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\1", $mes);
    } else {
        $mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\2", $mes);
    }
    $mes = '<span style="color:#FF2828;font-size:12px;">' . iconv("Windows-1251", "UTF-8//IGNORE", $mes) . '</style>';
    $message = $mes;
    $message = mysql_real_escape_string($message);
    $sel = myquery("SELECT `count` FROM `game_bot_chat_resp` WHERE `id` = '" . $char['name'] . "';");
    $n = mysql_fetch_array($sel);
    if ($n['count'] <= 4) {
        myquery("INSERT INTO `game_bot_chat_resp` (`id`,`count`) VALUES ('" . $char['name'] . "','1') ON DUPLICATE KEY UPDATE `count` = `count` + 1;");
        $update_chat = myquery("insert into game_log (town,fromm,too,message,date,ptype) values (0,'-1','" . $char['user_id'] . "','" . $message . "','" . time() . "'," . $priv . ")");
    } else {
        $sel = myquery("SELECT `text` FROM `game_bot_chat_annoy` ORDER BY RAND() ASC LIMIT 1");
        $mes = mysql_fetch_array($sel);
        if (!isset($char['sex']) || $char['sex'] == "male") {
            $mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\1", $mes);
        } else {
            $mes = preg_replace("/\\{([\\d\\w\\s]*?)\\|([\\d\\w\\s]*?)\\}/i", "\\2", $mes);
        }
        $message = mysql_real_escape_string('<span style="color:#FF2828;font-size:12px;">' . iconv("Windows-1251", "UTF-8//IGNORE", $mes['text']) . '</style>');
        $update_chat = myquery("insert into game_log (town,fromm,too,message,date,ptype) values (0,'-1','" . $char['user_id'] . "','" . $message . "','" . time() . "'," . $priv . ")");
    }
}
开发者ID:themiddleearth,项目名称:RPG.SU,代码行数:28,代码来源:index.php

示例3: profileDefault

 private function profileDefault($mode = 'run', $priceType = null)
 {
     if ($mode == 'info') {
         return ['name' => 'Базовый', 'description' => 'Профиль по умолчанию'];
     }
     if ($mode == 'run') {
         $offers = \app\models\Offers::find()->all();
         $arCsv = ['Название;Поставщик;Исходная цена;Посчитанная цена;Количество'];
         $providers = \app\models\Providers::find()->all();
         $arProviders = [];
         foreach ($providers as $value) {
             $arProviders[$value->id] = $value->name;
         }
         foreach ($offers as $offer) {
             $name = \app\components\Goods::getName($offer->goods_id);
             $provider = $arProviders[$offer->providers_id];
             $price = $offer->price;
             $quantity = $offer->quantity;
             //                print $name;
             $calcPrice = $price * \app\components\CalculationDiscount::calc($offer->goods_id, $offer->providers_id, $priceType);
             //                $calcPrice =  \app\components\CalculationDiscount::calc($offer);
             $arCsv[] = "{$name};{$provider};{$price};{$calcPrice};{$quantity}";
         }
         $csv = implode(chr(10), $arCsv);
         $this->_unloadStr('prise.csv', iconv('utf-8', 'windows-1251', $csv));
     }
 }
开发者ID:A111ex,项目名称:parser.ru,代码行数:27,代码来源:UnloadingController.php

示例4: sanitize

 public static function sanitize($text)
 {
     $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
     $text = trim($text, '-');
     $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
     return preg_replace('~[^-\w]+~', '', $text);
 }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:7,代码来源:seoTools.php

示例5: setCode

 /**
  * @brief 编码转换
  * @param string &$str 被转换编码的字符串
  * @param string $outCode 输出的编码
  * @return string 被编码后的字符串
  */
 public static function setCode($str, $outCode = 'UTF-8')
 {
     if (self::isUTF8($str) == false) {
         return iconv('GBK', $outCode, $str);
     }
     return $str;
 }
开发者ID:zydj333,项目名称:hualiangcaifu,代码行数:13,代码来源:ichar.php

示例6: buildXml

 /**
  * handle request and build XML
  * @access protected
  *
  */
 protected function buildXml()
 {
     if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
     }
     if (!isset($_GET["FileName"])) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
     }
     $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]);
     $_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
     if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $_resourceTypeInfo->checkIsHiddenFile($fileName)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
     }
     if (!$_resourceTypeInfo->checkExtension($fileName, false)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
     }
     $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
     $bDeleted = false;
     if (!file_exists($filePath)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
     }
     if (!@unlink($filePath)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
     } else {
         $bDeleted = true;
     }
     if ($bDeleted) {
         $thumbPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
         @unlink($thumbPath);
         $oDeleteFileNode = new Ckfinder_Connector_Utils_XmlNode("DeletedFile");
         $this->_connectorNode->addChild($oDeleteFileNode);
         $oDeleteFileNode->addAttribute("name", iconv('gbk', 'utf-8', $fileName));
         //$oDeleteFileNode->addAttribute("name", $fileName);
     }
 }
开发者ID:nathan1217,项目名称:ccad,代码行数:40,代码来源:DeleteFile.php

示例7: HandleAddItem

function HandleAddItem()
{
    define("CMD_ADD_OURITEM", <<<SQL
\t\tINSERT INTO our_items (name, our_category_id, art, mdate)
\t\t\tVALUES (?, ?, ?, NOW())
SQL
);
    define("CMD_SEL_OURITEM_NEWID", <<<SQL
\t\tSELECT id FROM our_items 
\t\t\tWHERE name = ? AND our_category_id = ? AND art = ?
SQL
);
    global $db;
    $newItem = iconv("UTF-8", "windows-1251", urldecode($_REQUEST["itemName"]));
    $art = "art" . $_REQUEST["parentNodeId"] . "_" . time();
    $res =& $db->query(CMD_ADD_OURITEM, array($newItem, $_REQUEST["parentNodeId"], $art));
    if (PEAR::isError($res)) {
        printError($res);
        exit;
    }
    $newId =& $db->getOne(CMD_SEL_OURITEM_NEWID, array($newItem, $_REQUEST["parentNodeId"], $art));
    if (PEAR::isError($newId)) {
        printError($newId);
        exit;
    }
    // ¬озвратить номер добавленой категории
    print trim($newId);
}
开发者ID:rivetweb,项目名称:old-auto-catalog,代码行数:28,代码来源:HandleAddItem.php

示例8: testLoadDOMDocumentUTF16

 /**
  * @depends testLoadDOMDocument
  */
 function testLoadDOMDocumentUTF16()
 {
     $xml = '<?xml version="1.0" encoding="UTF-16"?><root xmlns="DAV:">blabla</root>';
     $xml = iconv('UTF-8', 'UTF-16LE', $xml);
     $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
     $this->assertEquals('blabla', $dom->firstChild->nodeValue);
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:10,代码来源:XMLUtilTest.php

示例9: translate

 public static function translate($string)
 {
     $pinyin_table = self::$pinyin_table;
     $flow = array();
     $string = iconv('UTF-8', 'GB2312', $string);
     $length = strlen($string);
     for ($i = 0; $i < $length; $i++) {
         $h = ord($string[$i]);
         if ($h >= 0x81 and $h <= 0xfe) {
             if (isset($string[$i + 1])) {
                 $i++;
                 $l = ord($string[$i]);
                 if (isset($pinyin_table[$h][$l])) {
                     array_push($flow, $pinyin_table[$h][$l]);
                 } else {
                     array_push($flow, $h);
                     array_push($flow, $l);
                 }
             } else {
                 array_push($flow, ord($string[$i]));
             }
         } else {
             array_push($flow, ord($string[$i]));
         }
     }
     $pinyin = array();
     $size = sizeof($flow);
     for ($i = 0; $i < $size; $i++) {
         if (is_array($flow[$i])) {
             array_push($pinyin, $flow[$i][0]);
         }
     }
     return $pinyin;
 }
开发者ID:wangshipeng,项目名称:license,代码行数:34,代码来源:PinyinTranslator.php

示例10: utf_conv

 function utf_conv($iso, $charset, $what)
 {
     if (function_exists('iconv')) {
         $what = iconv($iso, $charset, $what);
     }
     return $what;
 }
开发者ID:cubis,项目名称:electronic-mis,代码行数:7,代码来源:localization.lib.php

示例11: prepare

 public static function prepare()
 {
     if ($_SERVER['CONTENT_TYPE'] && preg_match('/charset=([^;]*)/', $_SERVER['CONTENT_TYPE'], $matches)) {
         $encoding = strtoupper($matches[1]);
     } else {
         $encoding = ENCODING;
     }
     $urlencoded = strpos($_SERVER['CONTENT_TYPE'], 'urlencoded');
     foreach ($_REQUEST as $var => $val) {
         $value = $val;
         if ($urlencoded) {
             if (!is_array($value)) {
                 $value = urldecode($value);
             } else {
                 foreach ($value as $i => $v) {
                     $value[$i] = urldecode($v);
                 }
             }
         }
         if ($encoding and $encoding != ENCODING) {
             $value = iconv($encoding, ENCODING, $value);
         }
         $_REQUEST[$var] = $value;
     }
 }
开发者ID:rigidus,项目名称:SBIN-DIESEL,代码行数:25,代码来源:request.lib.php

示例12: do_iCMS

 public function do_iCMS($a = null)
 {
     if ($_GET['name']) {
         $name = $_GET['name'];
         $encode = mb_detect_encoding($name, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
         if (strtoupper($encode) != 'UTF-8') {
             if (function_exists('iconv')) {
                 $name = iconv($encode, 'UTF-8//IGNORE', $name);
             } elseif (function_exists('mb_convert_encoding')) {
                 $name = mb_convert_encoding($name, 'UTF-8//IGNORE', $encode);
             }
         }
         $val = iS::escapeStr($name);
         $field = 'name';
     } elseif ($_GET['tkey']) {
         $field = 'tkey';
         $val = iS::escapeStr($_GET['tkey']);
     } elseif ($_GET['id']) {
         $field = 'id';
         $val = (int) $_GET['id'];
     } else {
         iPHP::throw404('标签请求出错', 30001);
     }
     return $this->tag($val, $field);
 }
开发者ID:sunhk25,项目名称:iCMS,代码行数:25,代码来源:tag.app.php

示例13: PackMsg

 public function PackMsg($arr)
 {
     $bind = unserialize($arr['MessegeContent']);
     $packstr = $bind['PackFormat'];
     $res = pack($packstr, $bind['Length'], $bind['Length2'], $bind['uType'], $bind['MsgLevel'], $bind['Line'], $bind['CountDown'], iconv("utf-8", "GB2312", $bind['MessegeContent'] . ""));
     return $res;
 }
开发者ID:eappl,项目名称:prototype,代码行数:7,代码来源:SocketClient.php

示例14: PMA_aix_iconv_wrapper

/**
 * Wrapper around IBM AIX iconv(), whose character set naming differs
 * from the GNU version of iconv().
 *
 * @param   string   input character set
 * @param   string   output character set
 * @param   string   the string to convert
 *
 * @return  mixed    converted string or FALSE on failure
 *
 * @access  public
 *
 * @author  bwiberg  Björn Wiberg <Bjorn.Wiberg@its.uu.se>
 */
function PMA_aix_iconv_wrapper($in_charset, $out_charset, $str)
{
    global $gnu_iconv_to_aix_iconv_codepage_map;
    // Check for transliteration argument at the end of output character set name
    $translit_search = strpos(strtolower($out_charset), '//translit');
    $using_translit = !($translit_search === FALSE);
    // Extract "plain" output character set name (without any transliteration argument)
    $out_charset_plain = $using_translit ? substr($out_charset, 0, $translit_search) : $out_charset;
    // Transform name of input character set (if found)
    if (array_key_exists(strtolower($in_charset), $gnu_iconv_to_aix_iconv_codepage_map)) {
        $in_charset = $gnu_iconv_to_aix_iconv_codepage_map[strtolower($in_charset)];
    }
    // Transform name of "plain" output character set (if found)
    if (array_key_exists(strtolower($out_charset_plain), $gnu_iconv_to_aix_iconv_codepage_map)) {
        $out_charset_plain = $gnu_iconv_to_aix_iconv_codepage_map[strtolower($out_charset_plain)];
    }
    // Add transliteration argument again (exactly as specified by user) if used
    // Build the output character set name that we will use
    $out_charset = $using_translit ? $out_charset_plain . substr($out_charset, $translit_search) : $out_charset_plain;
    // NOTE: Transliteration not supported; we will use the "plain" output character set name
    $out_charset = $out_charset_plain;
    // Call iconv() with the possibly modified parameters
    $result = iconv($in_charset, $out_charset, $str);
    return $result;
}
开发者ID:alexhava,项目名称:elixirjuice,代码行数:39,代码来源:iconv_wrapper.lib.php

示例15: checkFileContent

 protected static function checkFileContent()
 {
     $fileContent = file_get_contents(static::$tmpFilepath);
     // check encoding and convert to utf-8 when necessary
     $detectedEncoding = mb_detect_encoding($fileContent, 'UTF-8, ISO-8859-1, WINDOWS-1252', true);
     if ($detectedEncoding) {
         if ($detectedEncoding !== 'UTF-8') {
             $fileContent = iconv($detectedEncoding, 'UTF-8', $fileContent);
         }
     } else {
         echo 'Zeichensatz der CSV-Date stimmt nicht. Der sollte UTF-8 oder ISO-8856-1 sein.';
         return false;
     }
     //prepare data array
     $tmpData = str_getcsv($fileContent, PHP_EOL);
     array_shift($tmpData);
     $preparedData = [];
     $data = array_map(function ($row) use(&$preparedData) {
         $tmpDataArray = str_getcsv($row, ';');
         $tmpKey = trim($tmpDataArray[0]);
         array_shift($tmpDataArray);
         $preparedData[$tmpKey] = $tmpDataArray;
     }, $tmpData);
     // generate json
     $jsonContent = json_encode($preparedData, JSON_HEX_TAG | JSON_HEX_AMP);
     self::$jsonContent = $jsonContent;
     return true;
 }
开发者ID:antic183,项目名称:php-fileupload-encrypt-json,代码行数:28,代码来源:CsvUploader.php


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