Returns the question of the Chinese display of JSON data
In the previous article, the Chinese returned in JSON format as \u5723\u8bde\u8282\u5343\u4e07\u597d\u793c\u5927\u5949\u9001
Workaround One:
Copy Code code as follows:
function Notice () {
Include './include/conn.php '; Database link File
$sql _notice = mysql_query (' SELECT * from gg_notice where enable = ' 1 ' limit 0,10 ');
$notice = mysql_fetch_array ($sql _notice, MYSQL_ASSOC);
$str = Json_encode ($notice);
conversion handle for use by the following two functions.(2) size_t iconv (iconv_t cd,char **inbuf,size_t *inbytesleft,char);This function reads characters from INBUF, converts them to Outbuf, Inbytesleft records the number of characters that have not yet been converted, outbytesleft the remaining space to record the output buffer. (3) int iconv_close (iconv_t CD);This function closes the conversion handle and frees the resource.
After testing, the following points need to be noted for using th
vvvv 10 vvvvvv 10 vvvvvv00010000 001 fffff 11110vvv 10 vvvvvv 10 vvvvvv 10 vvvvvv00200000 03 ffffff 111110vv 10 vvvvvv 10 vvvvvv 10 vvvvvv 10 vvvvvv04000000 7 fffffff 1111110 V 10 vvvvvv 10 vvvvvv 10 vvvvvv 10 vvvvvv 10 vvvvvvvv
This looks good. The English characters are the same as those in ASCII. So Americans are not aware of any mistakes. Only other countries in the world need high bytes.Specifically, the Unicode code point of the "hello" string is u + 0048 U + 0065 U + 006c U + 006c U + 00
ASCII codes)
NT/2000:
Len ("ABC China") returns 5 (because each character is considered Unicode)
Uft8
Utf8 is a storage and transfer format. As mentioned above, each Unicode/UCOS character is stored in 2 or 4 bytes. Let's take a look at the comparison below:
Take "I am Chinese" as an ExampleStorage with ANSI: 12 bytesSave with Unicode/ucs2: 24 bytes + 2Bytes (header)Stored with ucs4: 48 bytes + 4 bytes (header)
Take "I am a Chinese" as an ExampleStorage in ANSI: 10 bytesSave with Uni
decoding failures when the file is not encoded, put the loose encoding method at the end. For example, Latin1 is a very loose encoding method. The text obtained by any encoding method is decoded using Latin1 and will not fail to be decoded.-Of course, the decoded results are naturally "garbled ". Therefore, if you put Latin1 at the top of fileencodings, opening any Chinese file is garbled.
The following is a fileencodings setting recommended on the Internet:Set fileencodings =
Unicode only has one character set. The three characters in Chinese, Japanese, and Korean occupy part of Unicode 0 x to 0x9 fff Unicode is currently widely used in UCS-2, it uses two bytes to encode a character, for example, the Chinese character "jing" is encoded as 0x7ecf. Note that the character encoding is generally expressed in hexadecimal notation. to distinguish it from decimal notation, hexadecimal notation starts with 0x, and 0x7ecf is conver
Character Set and encoding
Abbreviations:
ASCII: American Standard Code for information interchange
UCs: Universal Character Set
UTF: Unicode/UCOS Transformation Format
ASCII code
The ASCII code is a 7-bit code with the encoding range of 0x00-0x7f. The ASCII character set includes English letters, Arabic numerals, punctuation marks, and other characters. 0x00-0x20 and 0x7f contain 33 control characters.
The system that only supports ASCII Code ignor
How to solve the problem of Chinese display in php json format,
Returns a question about Chinese display of json data.
In the previous article, the returned Chinese Characters in json format are displayed as \ u5723 \ u8bde \ u8282 \ u5343 \ u4e07 \ u597d \ u793c \ u5927 \ u5949 \ u9001
Solution 1:Copy codeThe Code is as follows:Function Notice (){Include './include/conn. php'; // database link file$ SQL _notice = mysql_query ('select * FROM gg_notice where enable = "1" limit 0, 10 ');$ Notice =
This article mainly introduces how to solve the problem of Chinese character display in PHPJSON format. This article summarizes three methods to solve the problem of Chinese character display starting with u, for more information about how to display json data in Chinese, see
In the previous article, the returned Chinese characters in json format are displayed as \ u5723 \ u8bde \ u8282 \ u5343 \ u4e07 \ u597d \ u793c \ u5927 \ u5949 \ u9001
Solution 1:
The code is as follows:
Function Notice (
This article mainly introduces how to solve the problem of Chinese character display in PHPJSON format. This article summarizes three methods to solve the problem of Chinese character display starting with u, for more information about how to display json data in Chinese, see
In the previous article, the returned Chinese characters in json format are displayed as \ u5723 \ u8bde \ u8282 \ u5343 \ u4e07 \ u597d \ u793c \ u5927 \ u5949 \ u9001
Solution 1:
The code is as follows:
Function Notice
) = [-2,-1, 95, 32, 78, 9]byte[] BGBK = name.getbytes (GBK); Name conversion to GBK after byte stream = [-43,-59,-56,-3]byte[] Butf8 = name.getbytes (UTF8); The byte stream after name is converted to UTF8 = [-27,-68,-96,-28,-72,-119]From this we can see that after executing string name = "Zhang San", the string stored is already the system default character encoded UTF16 (Big-endian).Perhaps the attentive person will find out why the "Zhang San" byte Count is [-2,-1, 95, 32, 78, 9] with 6 bytes?
expressed using multiple bytes to express a symbol. For example, the common encoding method in Simplified Chinese is GB2312, which uses two bytes to represent a Chinese character, so it is theoretically possible to represent a maximum of 256x256=65536 symbols.The issue of Chinese coding needs to be discussed in this article, which is not covered by this note. It is only pointed out that although a symbol is represented in multiple bytes, the Chinese character coding of the GB class is irrelevan
equivalent to 20-bit encoding, the value between 0 and 0x10ffff, basically is the implementation of Unicode encoding. it is a variable length code, which is related to the CPU order, but because it saves the most space, it is often used as an external code for network transmission.
The UTF-16 is Unicode preferred encoding.
UTF-32, Uses only 32-bit encoding in the Unicode range (0 to 0x10ffff), equivalent to a subset of the UCS-4.
UTF and
' Compilation ', ' compilation ', why the byte array length obtained is not the sameHttp://www.cnblogs.com/yongdaimi/p/5899328.htmlUnicode official websitehttp://unicode.org/Utf-8 Kanji Comparison TableHttp://blog.chinaunix.net/uid-25544300-id-3281847.htmlReference to inner and outer codeshttps://www.zhihu.com/question/27562173Code unit and Code pointhttp://www.jianshu.com/p/a7db6ac53d57Coding problem, write very fine, but at present do not understandHttp://www.fmddlmyy.cn/text6.htmlUnicoce code
mapping table and GBXX series are completely different, compared to a "medium" word, which is two distinct bytes in BIG5 and GB2312. There will be garbled, such as ("Tao Zhe" and "Taujigi"), a variety of Simplified Chinese and traditional transcoding tools appear.
What do you mean, BIG5?
Five Chinese packaged software: Clerical processing, database, trial table, communication, drawing. Basically, this set of codes is mainly used in these 5 areas.
Is it cumbersome for countries to use each coun
. Therefore, the English character is represented in 1 bytes, and the Chinese character is identified by two bytes.
Unicode for how to handle Chinese own text we can set up a set of coding specifications according to our own needs, but computers are not only used by Americans and Chinese, but also in Europe and other Asian countries such as Japanese, Korean all over the world to add up to an estimated hundreds of thousands of of the text, which has greatly exceeded the ASCII and even GBK can
platforms. When Unicode begins to develop, the memory capacity of the computer is greatly developed and space is no longer a problem. So ISO is directly required to use two bytes, that is, 16-bit to unify all the characters, for those "half-width" characters in ASCII, Unicode keeps its original encoding unchanged, only extending its length from 8 bits to 16 bits, while other cultures and language characters are all reunified. Because the "half angle" English symbol only needs to use the low 8 d
What is UTF8UTF8 is not a computer code, but a form of storage and transmission, as described above, each unicode/ucs character is stored in 2 or 4 bytes to see the following comparisons:Take "I am Chinese" as an exampleStore with ANSI: BytesStorage with UNICODE/UCS2: Bytes + 2 Bytes (header)Storage with UCS4: Bytes + 4 Bytes (header)Take the example of "I am Chinese"Store with ANSI: Ten BytesStorage with UNICODE/UCS2: Bytes + 2 Bytes (header)Storage
Brief introduction
Today's applications are often designed for international use. These applications may need to handle strings in different languages. Unicode is a language-independent character representation standard.
Because the Java programming language already uses Unicode internally to represent characters, the development of internationalized applications is much easier. However, you cannot consider only the application side. The back-end database must also be able to handle Unicode ch
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.