Encoding Preamble (mystic bytes at the begining of the utf-8,utf-16,utf-7 encoded stream)

Faced a problem with detecting file encoding when file is with no encoding preamble Bytes FE and FF (0xFE,0xFF) encoded useing given encoding. The problem was that flash movie, which uses xml data source as input parameter was not able to detect the encoding of the source. (.NET web form) I’ve solved this problem by writeing the preamble in the begining of the Http Response. I think problems of this kind hapens to many programmers.

I used C# code to solve the problem:

[code lang=”cpp”]
byte[] sign=Encoding.UTF8.GetPreamble();
Response.OutputStream.Write(sign,0,sign.Length);
[/code]

Xslt Transformer Windows Application (C# .NET)

XslTransformerThis application is a very easy to use and a very small tool. It is used to transform XML file useing the given XSL file.

Application uses System.Xml, System.Xml.Xslt namespaces and their classes to perform this action.

Application requires Microsoft .NET framework to run.

Please report any bug’s or suggestions related to this easy application.

The C#.NET source code is:
[code lang=”cpp”]
try
{
if ((outputF.ShowDialog()==DialogResult.OK)&&(outputF.FileName!=null)&&(outputF.FileName.Length>0))
{
XslTransform xslt=new XslTransform();
xslt.Load(label2.Text);
xslt.Transform(label1.Text,outputF.FileName);
label3.Text=”Complete …”;
}
else
{
label3.Text=”No transformation done …”;
}
}
catch(Exception Ex)
{
label3.Text=”No transformation done …”;
MessageBox.Show(Ex.ToString());
}
[/code]

https://i0.wp.com/are.ehibou.com/wp-content/plugins/downloads-manager/img/icons/default.gif?w=525 download: XsltTransformer.zip ()
added: 30/07/2010
clicks: 451
description: Xslt Transformer binary

https://i0.wp.com/are.ehibou.com/wp-content/plugins/downloads-manager/img/icons/default.gif?w=525 download: XsltTransformerSrc.zip ()
added: 30/07/2010
clicks: 381
description: Xslt Transformer source

Encoding Converter Windows Application (C#.NET)

Encoding Converter ThumbnalesThis 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:
[code lang=”cpp”]
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());
}
[/code]

https://i0.wp.com/are.ehibou.com/wp-content/plugins/downloads-manager/img/icons/default.gif?w=525 download: EncodingConverterSrc.zip ()
added: 30/07/2010
clicks: 690
description: Encoding Converter Source

https://i0.wp.com/are.ehibou.com/wp-content/plugins/downloads-manager/img/icons/default.gif?w=525 download: EncodingConverter.zip ()
added: 30/07/2010
clicks: 705
description: Encoding Converter binary