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


PHP Zend_Json_Encoder::encodeUnicodeString方法代码示例

本文整理汇总了PHP中Zend_Json_Encoder::encodeUnicodeString方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Json_Encoder::encodeUnicodeString方法的具体用法?PHP Zend_Json_Encoder::encodeUnicodeString怎么用?PHP Zend_Json_Encoder::encodeUnicodeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Json_Encoder的用法示例。


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

示例1: testEncodeUnicodeStringSolarRegression

 /**
  * @group ZF-4054
  */
 public function testEncodeUnicodeStringSolarRegression()
 {
     $value = 'héllö wørłd';
     $expected = 'h\\u00c3\\u00a9ll\\u00c3\\u00b6 w\\u00c3\\u00b8r\\u00c5\\u201ad';
     $this->assertEquals($expected, Zend_Json_Encoder::encodeUnicodeString($value));
     $value = "ä";
     $expected = '\\u00e4';
     $this->assertEquals($expected, Zend_Json_Encoder::encodeUnicodeString($value));
     $value = "ႠႨ";
     $expected = '\\u10a0\\u10a8';
     $this->assertEquals($expected, Zend_Json_Encoder::encodeUnicodeString($value));
 }
开发者ID:nbcutech,项目名称:o3drupal,代码行数:15,代码来源:JsonTest.php

示例2: _recursiveJsonExprFinder

 /**
  * Check & Replace Zend_Json_Expr for tmp ids in the valueToEncode
  *
  * Check if the value is a Zend_Json_Expr, and if replace its value
  * with a magic key and save the javascript expression in an array.
  *
  * NOTE this method is recursive.
  *
  * NOTE: This method is used internally by the encode method.
  *
  * @see encode
  * @param mixed $valueToCheck a string - object property to be encoded
  * @return void
  */
 protected static function _recursiveJsonExprFinder(&$value, array &$javascriptExpressions, $currentKey = null)
 {
     if ($value instanceof Zend_Json_Expr) {
         // TODO: Optimize with ascii keys, if performance is bad
         $magicKey = "____" . $currentKey . "_" . count($javascriptExpressions);
         $javascriptExpressions[] = array("magicKey" => is_int($currentKey) ? $magicKey : Zend_Json_Encoder::encodeUnicodeString($magicKey), "value" => $value->__toString());
         $value = $magicKey;
     } elseif (is_array($value)) {
         foreach ($value as $k => $v) {
             $value[$k] = self::_recursiveJsonExprFinder($value[$k], $javascriptExpressions, $k);
         }
     } elseif (is_object($value)) {
         foreach ($value as $k => $v) {
             $value->{$k} = self::_recursiveJsonExprFinder($value->{$k}, $javascriptExpressions, $k);
         }
     }
     return $value;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:32,代码来源:Json.php

示例3: testEncodeUnicodeStringSolarRegression

    /**
     * @group ZF-4054
     */
    public function testEncodeUnicodeStringSolarRegression()
    {
        $value    = 'héllö wørłd';
        $expected = 'h\u00c3\u00a9ll\u00c3\u00b6 w\u00c3\u00b8r\u00c5\u201ad';
        $this->assertEquals($expected, Zend_Json_Encoder::encodeUnicodeString($value));

        $value    = "\xC3\xA4";
        $expected = '\u00e4';
        $this->assertEquals($expected, Zend_Json_Encoder::encodeUnicodeString($value));

        $value    = "\xE1\x82\xA0\xE1\x82\xA8";
        $expected = '\u10a0\u10a8';
        $this->assertEquals($expected, Zend_Json_Encoder::encodeUnicodeString($value));
    }
开发者ID:nbcutech,项目名称:o3drupal,代码行数:17,代码来源:JsonTest.php


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