PHP解密Unicode及Escape加密字符串
来源:才华咖 本文已影响1.05W人
来源:才华咖 本文已影响1.05W人
在json中不支持中文,用它传送中文数据就会出现数据丢失或者乱码,必须在传送前对要发送的.字符串进行编码,由于传送过去需要用js进行数据解析,考虑 到js中有unescape函数,故若在php中有个escape函数,对数据进行编码,在客户端用unescape进行 解码,这样就会方便很多。
本文给大家分享一个PHP解密Unicode及Escape加密字符串函数
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
function uni_decode($s) {
preg_match_all('/&#([0-9]{2,5});/', $s, $html_uni);
preg_match_all('/[%]u([0-9a-f]{4})/ie', $s, $js_uni);
$source = array_merge($html_uni[0], $js_uni[0]);
$js = array();
for($i=0;$i<count($js_uni[1]);$i++) {
$js[] = hexdec($js_uni[1][$i]);
}
$utf8 = array_merge($html_uni[1], $js);
$code = $s;
for($j=0;$j<count($utf8);$j++) {
$code = str_replace($source[$j], unicode2utf8($utf8[$j]), $code);
}
return $code;//$s;//preg_replace('/u([0-9a-f]{4})/ie', "chr(hexdec('1'))", $s);
}
Zend studio for eclipse中使php可以调用mysql相关函数的设置方
Ought Parents to Give Children Pocket英语作文
英语阅读:Life is inevitable consequence of physics
How to Enhance the Sense of Happiness英语四级作文
Diaspora Finance Powers Global Development美文欣赏
关于Adobe为iPad版Photoshop Touch加入压敏触控笔支持
人教PEP版小学五年级英语下册Unit3Myschoolcalender.ALet’stalk
The place of Science and Technology in Modern Life英语作文
托福英语写作范文:Examinations exert a pernicious influence on educat
英语四级作文The Importance of Physical Exercise
Compare with the domestic hen and the duck英语作文
关于javascript中encodeURI和decodeURI的使用方法
英语阅读:VIT declines to acquire Ang Mo Kio property
DOS的Append、Debug、Diskcomp命令使用说明
The relationship between theory and practice大学英语作文
四级作文:Create a Conservation-Oriented Campus
英语四级作文Young People Should Have Ideals
英语作文The Importance of Self-confidence
意式咖啡 :「Cappucinno-卡布其诺」SCAE国际标准及解惑
初中英语作文--Can Money Buy Happiness
The truth about money and happiness高中英语作文
How Do My Parents Feel About My Education英语作文
豌豆上的公主英语作文 The Princess and the Pea
英语作文:The Importance of Self-confidence
PHP url 加密解密函数代码方法
Identifyingpeoplebyoccupation辨别身份实用英语口语
七年级英语Unit2Is this your pencil Period1说课稿
紧锣密鼓成语解析及造句
Keeping Healthy Topic2 Section C教案教学反思
Health in developing countries大学六级英语写作范文
英语阅读:Covergirl unveils empowering brand update
php中namespace use用法例子分析
AndroidApp中使用SurfaceView制作多线程动画的实例讲解
Chimp Cops Arbitrate Disputes美文欣赏
解密面试考官心理
带有密字的成语及解释
Changes in Peoples Life初中英语作文
英语报纸解读:Data may disrupt a peculiar business大纲
HCNP-Big Data-Developer V1.0试题及答案
A Letter to Univsity Pesident about the Canteen Service on C