I am trying to write a program in C# that will split a vCard (VCF) file with multiple contacts into individual files for each contact. I understand that the vCard needs to be saved as ANSI (1252) for most mobile phones to read them.
However, if I open a VCF file using StreamReader
and then write it back with StreamWriter
(setting 1252 as the Encoding format), all special characters like å
, æ
and ø
are getting written as ?
. Surely ANSI (1252) would support these characters. How do I fix this?
Edit: Here's the piece of code I use to read and write the file.
private void ReadFile()
{
StreamReader sreader = new StreamReader(sourceVCFFile);
string fullFileContents = sreader.ReadToEnd();
}
private void WriteFile()
{
StreamWriter swriter = new StreamWriter(sourceVCFFile, false, Encoding.GetEncoding(1252));
swriter.Write(fullFileContents);
}
StreamReader
that reads the VCF has the 1252 encoding set. – Shredding