本文整理汇总了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));
}
示例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;
}
示例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));
}