Single-Byte to full-byte-php Tutorial

Source: Internet
Author: User
The single-byte to wide-text Post was last edited by sevencolours24 at 2013-02-2816: 05: 54 $ msg "China". now we need to send this msg to another application for receiving, how to convert msg to UTF-16-encoded wide byte, the application can be normally displayed I am now directly sent to the past found to be single byte ----- single byte to wide byte

This post was last edited by sevencolours24 at 16:05:54

$ Msg = "China"
Now you need to send this msg to another application to receive it, and how to convert the msg to the width byte of the UTF-16 encoding for the application to display normally
I am sending it directly and found it is a single byte.


------ Solution --------------------
Read the manual and use the iconv return value.
$ Msg = iconv ('USC-2', 'utf-16', $ msg );
------ Solution --------------------
Wchar_t is a character data type of C/C ++ and is an extended character storage method. wchar_t is mainly used in the implementation of international programs, but it is not the same as unicode encoding. Unicode characters are generally stored as wchar_t. Char is an 8-character type and can contain a maximum of 256 characters. many foreign character sets contain more than 256 characters, which cannot be expressed as char.
The wchar_t data type is generally 16-bit or 32-bit, but different C or C ++ libraries have different requirements. for example, GNU Libc requires that wchar_t is 32-bit [1]. In short, wchar_t represents more than char characters.

So it can only be
Iconv ('utf-8', 'ucs-2', $ msg)
Iconv ('utf-8', 'ucs-4', $ msg)
Iconv ('utf-8', 'utf-16', $ msg)
Iconv ('utf-8', 'utf-32', $ msg)
One
------ Solution --------------------
Header ("content-type: text/html; charset = utf-8 ")
This is only the response header of the server.
Whether the encoding of your file is also utf-8. if the encoding is not uniform, garbled characters are normal.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.