0

I have a VCF file that contains my entire phonebook. I open it with Notepad and transferring data to windows form in c# via StreamReader. Some of vcard entries contains a row like:

"N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=42=75=72=73=61=6C=C4=B1;=4D=75=73=74=61=66=61;;;"

It looks like the line is UTF-8 code charset, but I have no idea how to convert it to a string.

Thanks for any advice.

Sertan Pekel
  • 593
  • 2
  • 5
  • 23

2 Answers2

2
using System.Net.Mail;

class Test
{

    public static string QPDecode(String str, String encoding)
    {
        Attachment attachment = Attachment.CreateAttachmentFromString("", "=?" + encoding + "?Q?" + str + "?=");
        return attachment.Name;
    }


    public static void Main(string[] args)
    {

        Console.WriteLine(QPDecode("=42=75=72=73=61=6C=C4=B1;=4D=75=73=74=61=66=61", "UTF-8"));
        //Bursalı;Mustafa

    }

}

How to extract the parts "UTF-8" and "=42=75=72=73=61=6C=C4=B1;=4D=75=73=74=61=66=61" from your file is left exercise to you :P

Esailija
  • 138,174
  • 23
  • 272
  • 326
0

The property value is in quoted-printable encoding, which is a standard encoding mechanism. You may be able to find a library that can decode it for you. Also, try this SO thread.

Community
  • 1
  • 1
Michael
  • 34,873
  • 17
  • 75
  • 109