This application is a very easy to use and a very small tool. It is used to convert a text file encoded using one encoding to the text file encoded using user specified encoding.
Application reads file data into a byte array and converts that byte array from one givven encoding to another. Application uses System.Text namespace and it’s class – Encoding, to perform this action.
Application requires Microsoft .NET framework to run.
It supports anny encoding supported by Microsoft .NET framework. The application was tested with windows-1257, windows-1251 and utf-8 encodings.
Please report any bug’s or suggestions related to this easy application.
The C#.NET source code is:
try
{
if (inputF.ShowDialog()==DialogResult.OK)
{
FileStream fs=File.OpenRead(inputF.FileName);
byte[] bytes=new byte[fs.Length];
fs.Read(bytes,0,(int)fs.Length);
fs.Close();
Encoding inputEnc=Encoding.GetEncoding(enc.Text);
Encoding outputEnc=Encoding.GetEncoding(outEnc.Text);
byte[] decoded=Encoding.Convert(inputEnc,outputEnc,bytes,0,bytes.Length);
if (outputF.ShowDialog()==DialogResult.OK)
{
FileStream fw=File.OpenWrite(outputF.FileName);
fw.Write(decoded,0,(int)decoded.Length);
fw.Close();
}
}
Status.Text="Status: "+ "Input file: "+inputF.FileName+" converted";
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
|
|
download: EncodingConverterSrc.zip (237.25KB) added: 30/07/2010 clicks: 384 description: Encoding Converter Source |
|
|
download: EncodingConverter.zip (194.10KB) added: 30/07/2010 clicks: 392 description: Encoding Converter binary |

Rather than having me type in the names of the encoding, how about detecting all encodings supported by the system and providing a drop down box?
Good idea. The next version will include this feature:)
Can you include the ability of converting all files and sub directories as well?
Good idea I’ll try to do this …
thanks.
I need to do conversion of thousands files from 1251 to utf8 encoding. Is it possible to use your tool from command prompt using wildcards or list of files as input parameter or in other batch mode?
If you need command line tool to do this I could easily change my application to do this for you … But please donate something … Or you can download source code and you can change it to your needs …