When developing a VCard, I found that when I found my fat six (Nokia6600) via MMS, The VCard always showed garbled characters. It is not like when the mobile phone sends a message to the mobile phone, it can be directly saved as a contact.
After several trials, we found that there was a problem with encoding.
The following is a normal string
BEGIN: VCARD FN; CHARSET = UTF-8: Xuzhong N; CHARSET = UTF-8 :;;;; ADR; DOM; CHARSET = UTF-8:; No. 6, xinlong Street, Hunnan New District ;;;; TEL; CELL: 13897905790 TEL; WORK: 23391584 EMAIL; INTERNET: xuzhong@nmc.ln139.com.cn ORG; CHARSET = UTF-8: Liaoning mobile company network management center system room END: VCARD |
Hexadecimal
It is the "ef bb bf" in front of it.
The file saved in ASCII code does not exist and can be normally displayed on the mobile phone.
I did not do this because of code conversion. I told him the problem and found the cause of the problem.
"Ef bb bf" is a UTF-8 code.
However, on the mobile phone, only the file starting with BEGIN: VCARD is recognized, and if the file is saved in ASCII code, the text section in the file becomes garbled.
Come up with a weird solution.
Create an ASCII code file, open it, and write UTF-8 streams to the file. :(
The method may be unscientific, but the problem is still solved. :) StreamWriter sw
= New StreamWriter ("c: \ myvcard. vcr", false, System. Text. Encoding. GetEncoding ("gb2312"), buff. Length );
Sw. Close ();
FileStream objFileStream
= New FileStream ("c: \ myvcard. vcr", FileMode. Append );
ObjFileStream. Write (buff, 0, buff. Length );
ObjFileStream. Close ();
Well, the problem can be solved within the prescribed time.