English 中文(简体)
UTF-8 in XML and JSON Schema
原标题:UTF-8 in XML and JSON Schema

在XML 和JSON Schema 混淆了图八

我的阵列如下:

$array = array(
    array( name => abc ,  text => اسلسصثصض صثصهخه عه☆anton & budi☆  ),
    array( name => xyz ,  text => nice  ),
);

when i convert it to XML it give me this result

<?xml version="1.0"?>
<response>
  <item>
    <name>abc</name>
    <text>&#x627;&#x633;&#x644;&#x633;&#x635;&#x62B;&#x635;&#x636; &#x635;&#x62B;&#x635;&#x647;&#x62E;&#x647; &#x639;&#x647;&#x2606;anton  &lt;&amp;&gt;  budi&#x2606;</text>
  </item>
  <item>
    <name>xyz</name>
    <text>nice</text>
  </item>
</response>

为什么结果如下:

<?xml version="1.0"?>
<response>
  <item>
    <name>abc</name>
    <text>اسلسصثصض صثصهخه عه☆anton &amp; budi☆</text>
  </item>
  <item>
    <name>xyz</name>
    <text>nice</text>
  </item>
</response>

And When i convert it to JSON it will give me result :

[
  {
    "name": "abc",
    "text": "u0627u0633u0644u0633u0635u062bu0635u0636 u0635u062bu0635u0647u062eu0647 u0639u0647u2606anton  <&>  budiu2606"
  },
  {
    "name": "xyz",
    "text": "nice"
  }
]

以及为什么不喜欢:

[
  {
    "name": "abc",
    "text": "اسلسصثصض صثصهخه عه☆anton &amp; budi☆"
  },
  {
    "name": "xyz",
    "text": "nice"
  }
]

is that any way to use utf-8 character inside xml or json ? or that s are the standard ?

问题回答

这可能是为了诊断和正确运输的更好可能性——系统一般在运输ASCII方面非常好,但许多系统在涉及其他编码时都字不提。

当然,应当能够正确运输UTF-8编码表格,但我怀疑你重新使用这一表格只是保守的。 这意味着,你不需要确保你在吉大港山区获得权利。 主要的方面是,它仍会给整个正确案文。 这是否给你造成某种实际问题,或者你是否对 escaping的使用感到惊讶?





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签