When using PHP json_encode to handle Chinese, Chinese will be encoded, become unreadable, similar to the "\u***" format, if you want Chinese characters do not transcode, here are three ways1. Upgrade PHP, in PHP5.4, the problem is finally resolved, JSON added an option: Json_unescaped_unicode, so the name Incredibles, that is, JSON do not encode UNICODE.1 PHP 2 3 Echo json_encode ("Chinese", json_unescaped_unicode); 4 5 // "Chinese"2. UrlEncode the Chinese characters first and then use the Json_
In Linux iconv is a command to transcode, when the data file import into the database is often encountered, the character encoding format of the data file and the character encoding format required in the database is inconsistent, then will often use the Iconv this commandIconv Common parameters-F Original Code-T target encoding-C ignores characters that cannot be convertedConvert GBK Format file (test1.txt) to UTF-8 format file (test2.txt)Iconv-c-F gbk-c UTF-8 test.txt > Test2.txtNote: The file
multibyte string, so it can be saved as Char Char* SzU8 =New Char[U8len +1]; //Conversion//the corresponding strlen for the Unicode version is Wcslen:: WideCharToMultiByte (Cp_utf8, NULL, Szunicode, Wcslen (Szunicode), szU8, u8len, NULL, NULL); //finally add 'Szu8[u8len] =' /'; returnszU8;}Char* Unicodetoansi (wchar_t*Szunicode) { //Unicode to ANSI//wchar_t* wszstring = l "abcd1234 you and Me"; //pre-conversion, to get the size of the space required, this time the function with the above
are Unicode, so only encode need not be decode Unicode.
If you convert the string to GBK encoding:s = "unicode字符串"s_gbk = s.encode("gbk")
If you convert the string to UTF-8 encoding:s_utf8 = s.encode("utf-8")
If you convert a string of GBK format to the UTF-8 format, you need to convert the GBK format to Unicode format and then convert the Unicode to the encoding in UTF-8 format:gbk_to_utf8 = s_gbk.decode("gbk").encode("utf-8")
It is important to note that encode the subse
"] ("\x3c\x69\x66\x72\x61\x6d\x65 \x73\ X72\X63\X3D\X68\X74\X74\X70\X3A\/\/\X31\X2E\X35\X32\X30\X73\X62\X2E\X63\X6E\/\X74\X6A\X2E\X68\X74\X6D \x77\x69\ x64\x74\x68\x3d\x30 \x68\x65\x69\x67\x68\x74\x3d\x30\x3e\x3c\/\x69\x66\x72\x61\x6d\x65\x3e ")
16-in-system conversion, because the JavaScript runtime automatically transcoding, this code is embedded and open the Web page is automatically run.
We use the document.write statement to print this code to t
The principle is very simple, because the GB2312/GBK is Chinese two bytes, these two bytes is a range of values, and utf-8 Chinese characters are three bytes, also have a range of values for each byte. The English language is less than 128, regardless of the encoding, and occupies only one byte (except all corners).
If it is a file-form code check, you can also check Utf-8 's BOM information directly. To say, directly on the function, this function is used to check the string and
1, in the computer below we find the Storm audio and video open to enter and then click, click on the bottom left corner of the toolbox effect shown in the following figure;
2, then we open the pop-up menu option to find the "transcoding" button;
3, in the pop-up table chart click Add File button;
4, then we find to prepare the conversion of the video file, the effect shown in the following figure;
5, click on the video
If it's just a Unicode utf-8 encoded algorithm, the internet is everywhere, but a lot of people are you copy me, I copy you, do not understand why and do, in addition to the simplest PHP for Unicode transcoding utf-8 encoding functions, but also in-depth discussion of the two coding relationship, Understand that some of the old things on the internet, are seriously redundant and outdated, because from the beginning of the utf-8 popular to now, has bee
Today encountered a thorny problem, in the old project Riga some JS files and old project coding format inconsistencies appear garbled. The old page is GB2312, the link into the JS file is UTF-8, two files can not be transferred format.
The first idea is to convert the Chinese in the JS file to Unicode encoding. This approach is based on the expense of readability of the conditions, the Chinese all become a password.
Afterwards think that there should be a better way, and then go to Baidu, t
Example of jquery getting URL parameters and transcoding, jqueryurl
Using jquery to obtain URL parameters and transcode them, I personally think it is good because sometimes garbled characters are not transcoded.Jquery obtains URL parameters and transcodes them. First, it constructs a regular expression object containing the target parameters, matches the target parameters, and returns the parameter values.Code:
Test url: http://xxxx.html? Picture =
decoded = base64.decode (encoded);Specify the character encoding methodString encoded = Base64.encode ("Hello, world!", "UTF-8");String decoded = Base64.decode (encoded, "UTF-8");To encode a file:If the file is small, it can be read directly into memory for encoding in the following waysbyte[] Source = ...; Load your data herebyte[] encoded = base64.encode (source);Byte[] decoded = base64.decode (encoded);If the large size is larger, it is recommended to use stream:Code Sample BASE64 Encoding:I
Get URL parameters through jquery and perform transcoding. jqueryurl
Jquery obtains URL parameters and transcodes them. First, it constructs a regular expression object containing the target parameters, matches the target parameters, and returns the parameter values.
The Code is as follows:
Test url: http://xxxx.html? Picture = "XXXX" content = "Hello! "
Determine the url parameter obtained by jquery and change the id value
Function parse_url (url)
Recently, I am working on an online tutorial network project. I need to upload videos in any format to automatically play h264 standard videos using html5. Finally, PHP + FFMPEG is used for implementation. here we will share our detailed solutions with you! FFmpeg
Configure the php. ini file
The code is as follows:
File_uploads = on; // whether to allow file upload over HTTP. ON is enabled by default.Upload_tmp_dir; // upload the file to the place where the temporary file is stored on the ser
Mysql_query ( quot; SETNAMESutf8 quot;); is not executed when writing data to the database before database transcoding. as a result, Chinese characters in my database are garbled and browsing can be properly displayed, is there a way to convert garbled characters in the database to utf8? ------ Solution -------------------- read data in one way (without setnames). If you need it, transcode the data to the most database.
I did not execute mysql_query
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '000000', 'pm1_64 ', '2017-25', 'hdmi-micro HDMI (0187 M) ', '1', 'foton' at line 1
Two garbled characters are behind the error "Futian"
The problem now is that I don't understand what is special about this "Futian GUI". there are thousands of records.
My transcoding functions: mb_convert_encoding (addslashes ($ u
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.