我目前正在为Android设计移动应用程序。文字和内容都在本地印度语,泰米尔语。对于欢迎,泰米尔语翻译相当于为:வணக்கம்
。由于Android无法显示印度语文字中,我使用一种名为的JavaScript字符串转义的转换了。
所以这个工作是这样的:
输入:வணக்கம்
输出: u0BB5 u0BA3 u0B95 u0BCD u0B95 u0BAE u0BCD
我怎么可以这样使用JavaScript或PHP,因为我有文字的巨大负载转换并使它成为JSON做。样品JSON:
{ 头衔: u0BAE u0BB0 u0BC1 u0BA4 u0BCD u0BA4 u0BC1 u0BB5 u0BB0 u0BBF u0BA9 u0BCD u0BAA u0BC6 u0BAF u0BB0 u0BCD#1, 形象:http://www.exceptnothing.com/doctors/doc11.png 评级: U2713 u0B87 u0BAA u0BCD u0BAA u0BC7 u0BBE u0BA4 u0BC1 u0BAA u0BBE u0BB0 u0BCD u0B95 u0BCD u0B95 u0BB2 u0BBE u0BAE u0BCD rating2:, releaseYear: u0BA8 u0BBE u0BB3 u0BCD u0BAE u0BC1 u0BB4 u0BC1 u0BB5 u0BA4 u0BC1 u0BAE u0BCD u0BAA u0BBE u0BB0 u0BCD u0B95 u0BCD u0B95 u0BB2 u0BBE u0BAE u0BCD 类型:[ u25B6 u0B87 u0BA4 u0BAF u0BA8 u0BBF u0BAA u0BC1 u0BA3 u0BB0 u0BCD]}
我也想知道如何去code以上JSON并显示为வணக்கம்
。先谢谢了。
你所寻找的是的 越狱()
JavaScript和的 json_en code()
在PHP。打开你的控制台,然后输入以下内容:
逃生(வணக்கம்)
,你会得到下面的回道:
%u0BB5%u0BA3%u0B95%u0BCD%u0B95%u0BAE%u0BCD
![Java字符类型 详解](https://p.xsw88.cn/allimgs/daicuo/20230907/6150.png)
因此,第一个被解决了。要回到原来的வணக்கம்
从上面的,使用的 UNESCAPE()
:
UNESCAPE(%u0BB5%u0BA3%u0B95%u0BCD%u0B95%u0BAE%u0BCD);
注:要注意的一件事是,无论的 越狱()
和的 UNESCAPE()
都去precated。所以,你需要使用连接codeURIComponent
和德codeURIComponent
的
preVIEW
更新服务器端
有关编码和解码成JSON,这是更好地为您使用PHP的内置功能。同样越狱()
,也可以在PHP作为的 json_en code()
,他们都产生相同的结果。
json_en code(வணக்கம்);= GT; %u0BB5%u0BA3%u0B95%u0BCD%u0B95%u0BAE%u0BCD
此外,请参阅的JavaScript:摆脱特殊字符了解详情。希望这可以帮助。 :)
I am currently designing a mobile application for Android. The text and content are in the Local Indic Language, Tamil. For Welcome, the equivalent of Tamil translation is: வணக்கம்
. Since Android cannot display Indic Text, I am converting it using a service called JavaScript String Escape.
So this works in this way:
Input:வணக்கம்
Output: u0BB5u0BA3u0B95u0BCDu0B95u0BAEu0BCD
How can I make this using JavaScript or PHP as I have huge loads of text to be converted and made it into JSON. Sample JSON:
{
"title": "u0BAEu0BB0u0BC1u0BA4u0BCDu0BA4u0BC1u0BB5u0BB0u0BBFu0BA9u0BCD u0BAAu0BC6u0BAFu0BB0u0BCD #1",
"image": "http://www.exceptnothing.com/doctors/doc11.png",
"rating": "u2713 u0B87u0BAAu0BCDu0BAAu0BC7u0BBEu0BA4u0BC1 u0BAAu0BBEu0BB0u0BCDu0B95u0BCDu0B95u0BB2u0BBEu0BAEu0BCD",
"rating2": "",
"releaseYear": "u0BA8u0BBEu0BB3u0BCD u0BAEu0BC1u0BB4u0BC1u0BB5u0BA4u0BC1u0BAEu0BCD u0BAAu0BBEu0BB0u0BCDu0B95u0BCDu0B95u0BB2u0BBEu0BAEu0BCD",
"genre": ["u25B6 u0B87u0BA4u0BAF u0BA8u0BBFu0BAAu0BC1u0BA3u0BB0u0BCD"]
}
I also would like to know how to decode the above JSON and show it as வணக்கம்
. Thanks in advance.
What you are looking for is escape()
in JavaScript and json_encode()
in PHP. Open up your console and type the following:
escape("வணக்கம்")
And you will get the following back:
"%u0BB5%u0BA3%u0B95%u0BCD%u0B95%u0BAE%u0BCD"
So the first one is solved. To get back the original வணக்கம்
from the above one, use unescape()
:
unescape("%u0BB5%u0BA3%u0B95%u0BCD%u0B95%u0BAE%u0BCD");
Note: One thing to be noted is, both escape()
and unescape()
are deprecated. So you need to use encodeURIComponent
and decodeURIComponent
Preview
Update for Server Side
For encoding and decoding into JSON, it is better for you to use the PHP's built-in function. The same escape()
can also be used in PHP as json_encode()
, they both give the same result.
json_encode("வணக்கம்");
=> "%u0BB5%u0BA3%u0B95%u0BCD%u0B95%u0BAE%u0BCD"
Also, see JavaScript: Escaping Special Characters for more information. Hope this helps. :)
相关推荐
最新文章