本文整理匯總了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));
}