Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to open a txt file in my code, but this file is in ANSI (windows 1255) encoding, and convert it to UTF-8. How can I do that?
Posted
Comments
Sergey Alexandrovich Kryukov 15-Jan-12 4:16am    
What's the problem, MSDN hates you or Google banned you?
--SA

1 solution

Let's do it quickly: read it with
C#
System.IO.StreamReader reader =
    new System.IO.StreamReader(fileName, System.Text.ASCIIEncoding.ASCII, false);
write with
C#
System.IO.StreamWriter writer =
    new System.IO.StreamWriter(fileName, false, System.Text.UTF8Encoding.UTF8);


—SA
 
Share this answer
 
v2
Comments
Richard MacCutchan 15-Jan-12 10:26am    
Just what I needed, have a 5.
Bahare Aghabarari 17-Feb-13 3:07am    
Thanks very much*

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900