[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1895
  • Last Modified:

C# 1256 file encoding

Hello
I am facing an encoding problem.
I want to write information to a file ( Arabic Letters ( windows-1256 ) ), but the letters are written in UTF-8 , here is the code :

FileStream afile = new FileStream ("school_db.sql", FileMode .OpenOrCreate);
StreamWriter sw = new StreamWriter (afile);
string test = "شكرا على المساعدة ";
sw.WriteLine(test);
sw.Close ();


So I want to convert the variable :' test' to windows-1265 befor writing it to the file.
Thank you for your help
Regards


0
ad-sol
Asked:
ad-sol
1 Solution
 
PockyMasterCommented:
You are pointing at this?

System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1256);
System.IO.StreamWriter sw = new System.IO.StreamWriter("c:\test", false, enc);
0
 
ad-solAuthor Commented:
Yes, it is working now,
Thank you PockyMaster
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now