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


PHP iconv_set_encoding函数代码示例

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


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

示例1: testBasic

 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     iconv_set_encoding('internal_encoding', 'UTF-8');
     /**
      * The elements of each array are, in order:
      *      - minimum length
      *      - maximum length
      *      - expected validation result
      *      - array of test input values
      */
     $valuesExpected = array(
         array(0, null, true, array('', 'a', 'ab')),
         array(-1, null, true, array('')),
         array(2, 2, true, array('ab', '  ')),
         array(2, 2, false, array('a', 'abc')),
         array(1, null, false, array('')),
         array(2, 3, true, array('ab', 'abc')),
         array(2, 3, false, array('a', 'abcd')),
         array(3, 3, true, array('äöü')),
         array(6, 6, true, array('Müller'))
         );
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_StringLength($element[0], $element[1]);
         foreach ($element[3] as $input) {
             $this->assertEquals($element[2], $validator->isValid($input));
         }
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:33,代码来源:StringLengthTest.php

示例2: __construct

 /**
  * Constructs a new Zend_Service_Technorati instance
  * and setup character encoding.
  *
  * @param  string $apiKey  Your Technorati API key
  */
 public function __construct($apiKey)
 {
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
     $this->_apiKey = $apiKey;
 }
开发者ID:netvlies,项目名称:zf,代码行数:13,代码来源:Technorati.php

示例3: _initEncoding

 /**
  * Устанавливаем кодировку UTF-8 для функций mb_*
  *
  */
 protected function _initEncoding()
 {
     if (phpversion() < 5.6) {
         mb_internal_encoding('utf-8');
         iconv_set_encoding('internal_encoding', 'utf-8');
     }
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:11,代码来源:BootstrapQuick.php

示例4: send_pay

 public function send_pay()
 {
     $config = $this->config;
     $p1_MerId = $config['id'];
     //"10001126856";
     $merchantKey = $config['key'];
     //"69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl";
     $logName = $config['error_log'] = "YeePay_HTML.log";
     $reqURL_onLine = "https://www.yeepay.com/app-merchant-proxy/node";
     //产品通用接口请求地址
     $p0_Cmd = "Buy";
     //支付请求,固定值"Buy" .
     $p9_SAF = "0";
     //送货地址,默认为0
     //	商家设置用户购买商品的支付信息.
     //易宝支付平台统一使用GBK/GB2312编码方式,参数如用到中文,请注意转码
     //	商户订单号,选填.
     //若不为"",提交的订单号必须在自身账户交易中唯一;为""时,易宝支付会自动生成随机的商户订单号.
     $p2_Order = $config['code'];
     //	支付金额,必填.
     //单位:元,精确到分.
     $p3_Amt = $config['money'];
     //	交易币种,固定值"CNY".
     $p4_Cur = "CNY";
     //	商品名称
     //用于支付时显示在易宝支付网关左侧的订单产品信息.
     $p5_Pid = htmlspecialchars(trim($config['title']));
     //iconv("UTF-8","GBK","你妹xxxx")
     //	商品种类
     $p6_Pcat = '';
     //	商品描述
     $p7_Pdesc = '';
     //	商户接收支付成功数据的地址,支付成功后易宝支付会向该地址发送两次成功通知.
     $p8_Url = $config['NotifyUrl'];
     //	商户扩展信息
     //商户可以任意填写1K 的字符串,支付成功时将原样返回.
     $pa_MP = '';
     //	支付通道编码
     //默认为"",到易宝支付网关.若不需显示易宝支付的页面,直接跳转到各银行、神州行支付、骏网一卡通等支付页面,该字段可依照附录:银行列表设置参数值.
     if ($config['pay_bank'] == 'DEFAULT') {
         $pd_FrpId = '';
     } else {
         $pd_FrpId = $config['pay_bank'];
     }
     //	应答机制
     //默认为"1": 需要应答机制;
     $pr_NeedResponse = "1";
     //调用签名函数生成签名串
     iconv_set_encoding("internal_encoding", "UTF-8");
     iconv_set_encoding("output_encoding", "GBK");
     // 开始缓存
     ob_start("ob_iconv_handler");
     include dirname(__FILE__) . '/yeepay/yeepayCommon.class.php';
     $yeepayCommon = new yeepayCommon();
     $yeepayCommon->config = $config;
     $hmac = $yeepayCommon->getReqHmacString($p2_Order, $p3_Amt, $p4_Cur, $p5_Pid, $p6_Pcat, $p7_Pdesc, $p8_Url, $pa_MP, $pd_FrpId, $pr_NeedResponse);
     include dirname(__FILE__) . '/yeepay/yeepay_send.tpl.php';
     ob_end_flush();
     exit;
 }
开发者ID:shuay,项目名称:projectYG,代码行数:60,代码来源:yeepay.class.php

示例5: doRequest

 /**
  * Perform a JSON-RPC request and return a response.
  *
  * @param Zend_XmlRpc_Request $request
  * @param null|Zend_XmlRpc_Response $response
  * @return void
  * @throws Zend_XmlRpc_Client_HttpException
  */
 public function doRequest($request, $response = null)
 {
     $this->_lastRequest = $request;
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
     $http = $this->getHttpClient();
     if ($http->getUri() === null) {
         $http->setUri($this->_serverAddress);
     }
     $http->setHeaders(array('Content-Type: text/xml; charset=utf-8', 'Accept: text/xml'));
     if ($http->getHeader('user-agent') === null) {
         $http->setHeaders(array('User-Agent: Zend_XmlRpc_Client'));
     }
     $xml = $this->_lastRequest->__toString();
     $http->setRawData($xml);
     $httpResponse = $http->request(Zend_Http_Client::POST);
     if (!$httpResponse->isSuccessful()) {
         /**
          * Exception thrown when an HTTP error occurs
          * @see Zend_XmlRpc_Client_HttpException
          */
         // require_once 'Zend/XmlRpc/Client/HttpException.php';
         throw new Zend_XmlRpc_Client_HttpException($httpResponse->getMessage(), $httpResponse->getStatus());
     }
     if ($response === null) {
         $response = new Zend_XmlRpc_Response();
     }
     $this->_lastResponse = $response;
     $this->_lastResponse->loadXml($httpResponse->getBody());
 }
开发者ID:EvanDotPro,项目名称:cosmos,代码行数:39,代码来源:Client.php

示例6: getEncoding

 /**
  * Retrieves the encoding
  *
  * @return string
  * @throws Glitch_Application_Resource_Exception
  */
 public function getEncoding()
 {
     if (null === $this->_encoding) {
         // Test for UTF-8 support. The regex will wrongly match 4 chars,
         // rather than 2, if PCRE was compiled without UTF-8 support. If the chars
         // in preg_match appear garbled, change the encoding of this file to UTF-8!
         if (!extension_loaded('iconv') || !preg_match('~^..$~u', '±')) {
             throw new Glitch_Application_Resource_Exception('No multibyte strings support');
         }
         $options = $this->getOptions();
         // Force these options to be set - don't rely on the defaults!
         if (!isset($options['encoding'])) {
             throw new Glitch_Application_Resource_Exception('Undefined encoding option: "encoding"');
         }
         $this->_encoding = (string) $options['encoding'];
         // Override the default charset; also sends the appropriate HTTP header
         ini_set('default_charset', $this->_encoding);
         // ZF uses iconv for e.g. form validation and Zend_Locale
         iconv_set_encoding('internal_encoding', $this->_encoding);
         // MB extension is not required by ZF, so don't throw exceptions
         if (function_exists('mb_internal_encoding')) {
             // ZF uses this for e.g. Zend_Filter and Zend_Feed
             mb_internal_encoding($this->_encoding);
         }
         // Allow application-wide access; e.g. Zend_Mail uses this
         Glitch_Registry::setEncoding($this->_encoding);
     }
     return $this->_encoding;
 }
开发者ID:nstapelbroek,项目名称:Glitch_Lib,代码行数:35,代码来源:Encoding.php

示例7: call

 public function call()
 {
     $app = $this->app;
     // Set encoding
     if (function_exists('iconv') && PHP_VERSION_ID < 50600) {
         // These are settings that can be set inside code
         iconv_set_encoding('internal_encoding', 'UTF-8');
         iconv_set_encoding('input_encoding', 'UTF-8');
         iconv_set_encoding('output_encoding', 'UTF-8');
     } elseif (PHP_VERSION_ID >= 50600) {
         ini_set('default_charset', 'UTF-8');
     }
     mb_internal_encoding($app->charset);
     // Configure timezone
     date_default_timezone_set($app->timezone);
     // Share the cryptor for the app
     if ($_crypt = $app->get($this->injectors['cryptor'])) {
         $app->cryptor = function () use($_crypt) {
             return new Cryptor($_crypt);
         };
     }
     // Share the logger for the app
     if ($_log = $app->get($this->injectors['logger'])) {
         $app->logger = Logger::$default = new Logger($_log);
     }
     $this->next();
 }
开发者ID:pagon,项目名称:framework,代码行数:27,代码来源:Booster.php

示例8: toASCII

 /**
  * Convert a string to ASCII
  *
  * @access public
  * @param  string $str     The string to convert
  * @param  string $charset The default charset to use
  * @return string The converted string
  */
 public static function toASCII($str, $charset = 'UTF-8')
 {
     $asciistr = '';
     if (mb_detect_encoding($str, 'UTF-8', true) === false) {
         $str = utf8_encode($str);
     }
     if (version_compare(PHP_VERSION, '5.6.0') < 0) {
         iconv_set_encoding('input_encoding', 'UTF-8');
         iconv_set_encoding('internal_encoding', 'UTF-8');
         iconv_set_encoding('output_encoding', $charset);
     }
     $str = html_entity_decode($str, ENT_QUOTES, $charset);
     $strlen = iconv_strlen($str, $charset);
     for ($i = 0; $i < $strlen; $i++) {
         $char = iconv_substr($str, $i, 1, $charset);
         if (!preg_match('/[`\'^~"]+/', $char)) {
             if ('UTF-8' === $charset) {
                 $asciistr .= preg_replace('/[`\'^~"]+/', '', iconv($charset, 'ASCII//TRANSLIT//IGNORE', $char));
             } else {
                 $asciistr .= preg_replace('/[`\'^~"]+/', '', iconv('UTF-8', $charset . '//TRANSLIT//IGNORE', $char));
             }
         } else {
             $asciistr .= $char;
         }
     }
     return $asciistr;
 }
开发者ID:nextinteractive,项目名称:utils,代码行数:35,代码来源:StringUtils.php

示例9: __construct

 /**
  * Sets up character encoding, instantiates the HTTP client, and assigns the web service version.
  */
 public function __construct()
 {
     $this->set('version', '1.0');
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
 }
开发者ID:ramonornela,项目名称:Zebra,代码行数:10,代码来源:Audioscrobbler.php

示例10: setOutputEncoding

 /**
  * @param string $encoding
  *
  * @return bool|string
  */
 public static function setOutputEncoding($encoding)
 {
     if (self::versionGreaterOrEquals56()) {
         return ini_set('output_encoding', $encoding);
     }
     return iconv_set_encoding('output_encoding', $encoding);
 }
开发者ID:emagister,项目名称:zendframework1,代码行数:12,代码来源:EncodingProxy.php

示例11: __construct

 /**
  * Sets up character encoding, instantiates the HTTP client, and assigns the web service version.
  */
 public function __construct(HttpClient $httpClient = null)
 {
     $this->setHttpClient($httpClient ?: new HttpClient());
     $this->set('version', '1.0');
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
 }
开发者ID:allan2012,项目名称:laraspiked,代码行数:11,代码来源:Audioscrobbler.php

示例12: __construct

 /**
  * Constructs a new Zend\Service\Technorati instance
  * and setup character encoding.
  *
  * @param  string $apiKey  Your Technorati API key
  */
 public function __construct($apiKey, HttpClient $httpClient = null)
 {
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
     $this->apiKey = $apiKey;
     $this->setHttpClient($httpClient ?: new HttpClient());
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:14,代码来源:Technorati.php

示例13: __construct

 /**
  * Zend_Service_Flickr Constructor, setup character encoding
  *
  * @param string $apiKey Your Flickr API key
  */
 public function __construct($apiKey)
 {
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
     $this->apiKey = $apiKey;
     $this->_rest = new Zend_Rest_Client('http://www.flickr.com');
     $this->_array = array();
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:Flickr.php

示例14: setEncoding

 public function setEncoding(string $type = 'input', string $charset = 'utf-8') : bool
 {
     if (!in_array($type, $this->inputs)) {
         throw new InvalidArgumentException('Error', 'invalidInput', $type);
     }
     if (!isCharset($charset)) {
         throw new InvalidArgumentException('Error', 'charsetParameter', '2.($charset)');
     }
     return iconv_set_encoding($type . '_encoding', $charset);
 }
开发者ID:znframework,项目名称:znframework,代码行数:10,代码来源:InternalIV.php

示例15: mb_internal_encoding

 function mb_internal_encoding($enc = FALSE)
 {
     if (function_exists('iconv_set_encoding')) {
         if ($enc) {
             iconv_set_encoding('internal_encoding', $enc);
         }
         return iconv_get_encoding('internal_encoding');
     }
     return '';
 }
开发者ID:chaobj001,项目名称:tt,代码行数:10,代码来源:func_mbstring.php


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