To make a homemade POP3 mail receiving system, you have to process your email code.
Everyone may receive the following "garbled", ~ {4S
In fact, it is the HZ coding of Simplified Chinese. It often occurs in the email.
Because the email protocol system is usually seven, the Chinese characters are double-bytes.
So use the following method to decode it
String hzdecode (match m) {string TMP = m.toString (); byte [] ret = new byte [tmp.Length-4]; for (int i = 0; i
Example of use: string strhz = "~ {4S
Example: String strhz = "Hello everyone, I am Qiushuiwuhen, welcome to 9CBS."; StrHz = regex.replace (strHz, @ "[^ / x00- / xff] ", new matchevaluator (hzencode); response .Write ("
hz encode =" strHz);
Principle: Using Matchevaluator's callback function to perform Regex's replacement operation