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.