1STD::string Msgfieldlist::gbtoutf8 (std::string Des,Const Char*str)2 {3WCHAR *strsrc;4TCHAR *Szres;5 6 //get the size of a temporary variable7 inti = MultiByteToWideChar (CP_ACP,0, str,-1Null0);8STRSRC =Newwchar[i+1];9MultiByteToWideChar (CP_ACP,0, str,-1, STRSRC, i);Ten One //get the size of a temporary variable Ai = WideCharToMultiByte (Cp_utf8,0, STRSRC,-1Null0, NULL, NULL); -Szres =Newtchar[i+1]; - intJ=widechartomultibyte (Cp_utf8,0, STRSRC,-1, szres, I, NULL, NULL); t
Why do I need to transcode?Four scenarios where the client sends a request to the server: 1, direct access to the URL method; 2, the page link (belongs to get request); 3. Form get Submit ; 4. Form Post Submission1.url (URL and page link): Each big browser, each operating system of the URL Uri, querystring encoding may be different . Tomcat decoding of URIs is the first to get the connector of the decoder set, the configuration is in Server.xml , "Utf-8"/> is parsed with the default encoding iso
php5.4 before the Json_encode when the Chinese will be Unicode encoding, Chinese will be encoded, become unreadable, similar to the "\u***" format, but also to a certain extent, increase the amount of data transferred.
For example:
Copy CodeThe code is as follows:
$str = ' Chinese ';
echo Json_encode ($STR);
"\u4e2d\u6587"
php5.4 start
Echo Json_encode ($str, Json_unescaped_unicode);
Chinese
php5.4 let JSON know more Chinese!
no Unicode transcoding
Questions about the output after character transcoding
Header ("content-type:text/plain;charset=gb2312");
Header ("Content-disposition:attachment;filename=". Date ("Ymdhis"). " Test.xls ");
echo iconv ("UTF8", "gb2312", "Weibo id\t");
Why is there no data in the exported Excel table?
If you rewrite the UTF8 in the Iconv function to Utf-8, there is no problem.
Please explain why, thank you.
------Solution--------------------
UTF8 is UTF8 encode
When iconv encounters a character that cannot be transcoded, the interrupted content is lost. the code is as follows: $ c amp; lsquo; test amp; bull; character transfer amp; bull; Happy May Day! Amp; rsquo; echoiconv ( amp; lsquo; UTF-8 amp; prim
Iconv is interrupted when transcoding fails. the code is as follows:
$ C = 'Test • character transfer • Happy May Day! ';
Echo iconv ('utf-8', 'gbk', $ c );
Only output: After the test,
The new stringentity (params, "Utf-8") is specified as Utf-8 encoding try {HttpClient client = new Defaulthttpclient (); HttpPost HttpPost = new HttpPost (URL);//set encoding to prevent Chinese transmission garbled stringentity entity = new Stringentity (contentvalue.tostring (), " Utf-8 "); httppost.setentity (entity);HttpResponse response = Client.execute (HttpPost); Get the response code status = Response.getstatusline (). Getstatuscode ();//status = Response.getstatusline (). Getstatuscode (
1, RMVB extract audio for MP3Ffmpeg-i XXX.RMVB Xxx.mp32. Intercept by Time rangeFfmpeg-i xxx.rmvb-ss 00:00:10-t 00:10:00 Xxx.mp3-ss Intercept Start time-T intercept duration3, the video quality of conversionFfmpeg-i Xxx.rmvb-qscale xxx.flv-qscale is the quality of the video output, the lower the value the higher the image, but the larger the output file4. Converted Video sizeFfmpeg-i xxx.rmvb-s 640*480 xxx.flv-S convert video file size5, the interception of the specified time thumbnailFfmpeg-i x
Now do a PHP ubb transcoding. It is useful to use the code highlighting plugin, which is
If I use NL2BR, every line will add
, there are also in the pre, causing
be called out.
If not added, then multiple lines of text will be displayed to one line. The user experience is affected if the user is asked to consider adding [BR] or empty two lines to represent a br.
So ask, how to add BR in the place plus BR, such as ordinary multi-line text, should not
Database transcoding
Before in the database to write the data did not execute mysql_query ("SET NAMES UTF8"), cause my database of Chinese is garbled, browse is can normal display, ask there is no way to convert the database garbled, converted to UTF8?
------Solution--------------------
read out in one way (without set names), transcode if necessary, and finally deposited in another way (plus set names).
------Solution--------------------
Library/
Iconv-convert string to requested character encoding (PHP 4 >= 4.0.5, PHP 5)
Mb_convert_encoding-convert character encoding (PHP 4 >= 4.0.6, PHP 5)
Usage:
Iconv
String Iconv (String $in _charset, String $out _charset, String $str)
Converts a string from one specified encoding to another specified encoding. Note that the second parameter adds two suffixes, in addition to the encoding you can specify to convert to. Translit automatically converts characters that cannot be converted directly into o
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.