Several small coding experiences

Source: Internet
Author: User

1. The charset of ADODB. Stream does not convert the encoding, but only changes the reading and writing methods. If you use stream to read a file, change charset, and save it, the encoding does not actually change. The correct method is to change charset, read, and then savetofile.

2. encoding options for XML. XML reads UTF-8 by default? XML version = '1. 0' encoding =...>, the program changes to the encoding reading method. Therefore, if your xml file is not saved in UTF-8, you must write it clearly in encoding; otherwise, errors may occur. XML will also try to read files in Unicode mode, but I think few people dare to use Unicode to save data.

3. the XMLHTTP web page is garbled. XMLHTTP crawls webpages Based on UTF-8 by default. Therefore, for UTF-8 webpages such as csdn, the webpage is captured normally. However, most websites in China use gb2312 encoding, which leads to garbled characters. The solution is to use ADODB. Stream for transcoding.

4. Two questions about encoding. A. For the gb2312 page captured by XMLHTTP, if responsebody is directly displayed in <textarea>, the page may be frozen. B. If strings other than ascii or gb2312 are saved in FO, a file error rather than an Encoding Error is displayed. These strings are often cheated during debugging. C. netant cannot read Unicode lst files, which is quite unpleasant.

5. About automatic GB and big5 recognition. Big5 and GB are both two-byte encoded values, but their encoding ranges slightly different. The first gb2312 byte is between 81-fe, And the last byte is between 40-fe, removing a line of xx7f. GBK first byte between OXAO-OXFE, two byte between OX40-OX7E and OXA1-OXFE. By comparing the encoding range in the text, you can roughly determine the encoding type.

6. Window notepad, editplus, and other text files are saved in ASCII format by default. This is because there is no encoding instructions in the file header, and the content is directly opened in binary mode. However, when it is saved in unicod or utf8 mode, a direct encoding instruction is provided before. This byte is invisible in notepad, but in ADODB. when reading binary tools such as stream, it will load them together. If you don't pay attention to it, it is easy to make a little effort.

7. In the ACCESS database, if a field stores a katakana in Japanese, an error occurs when you use like or instr to search for it. The solution is to use bin instead of TXT to store Japanese files.

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.