[CSharp] VCard encountered Encoding Problems

Source: Internet
Author: User
Tags vcard
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.

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.