My own page is coded in UTF-8. However, the problem is that on this page, a variable needs to be sent out after MD5 encryption, and the other party uses gb2312 encoding. This MD5 process contains Chinese variables, the encryption result is different from the encryption result of this variable. The reason is that the variable is the internal code of the UTF-8 when it is passed out, and the other party will explain it with gb2312 after receiving it. To solve this problem, you must convert the variable into gb2312 encoding before encryption.
I found n methods on the Internet, including utf2gb functions .. All of them are invalid or unsatisfactory. Some of them, although the encoding is successfully encrypted, are uploaded to the other party and the group is garbled.
Just as the mountains and waters are exhausted, we suddenly find that we can do this on the same page.CodeEncoding mode switch. This ensures that the code of the entire website page remains unchanged. You can use different encoding methods for a variable or part of the code segment on the page:
See the following page:
<% @ Language = "VBScript" codePage = "65001" %> <br/> <% <br/> response. code Page = 65001 <br/> response. charset = "UTF-8" <br/>%> <br/> <! -- # Include file = "md5.asp" --> <br/> <% <br/> dim A: A = "Chinese" <br/> dim B <br/> response. write (A & "<br>") <br/> B = MD5 (a) <br/> response. write (B & "<br>") </P> <p> 'start to change the encoding method <br/> response. code Page = 936 <br/> response. charset = "GBK" <br/> response. write (A & "<br>") <br/> B = MD5 (a) <br/> response. write (B & "<br>") </P> <p> 'Restore encoding method <br/> response. code Page = 65001 <br/> response. charset = "UTF-8" <br/> response. write (A & "<br>") <br/> B = MD5 (a) <br/> response. write (B & "<br>") <br/> %>
The running result is as follows: Garbled characters are actually the content of gb2312 encoding displayed on the UTF-8 page. If the receiver is gb2312, it can be correctly displayed.
Chinese
249ba6277758050695e8f5909bacd6d3
��
F3b679619b195beba139fcbb4b486630
Chinese
249ba6277758050695e8f5909bacd6d3