Re: Finding out a file encoding
From: Morten Wennevik (MortenWennevik_at_hotmail.com)
Date: 09/07/04
- Next message: Morten Wennevik: "Re: Search in an Array"
- Previous message: carmen: "Re: close application after CreateProcess"
- In reply to: Gaia C via .NET 247: "Finding out a file encoding"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 07 Sep 2004 09:30:34 +0200
Hi Gaia,
You should do
byte[] p = Encoding.Unicode.GetPreamble();
And then test the first bytes in your file against these bytes for each possible encoding.
This may work for unicode encoded files since I believe they add a mark to the file to specify endianess. However, you are not guaranteed to detect the file encoding this way because
1: The encoding may not have an identifying mark.
2: Your file may not have an identifying mark.
I don't think any ANSI encoded files have an identifying mark.
-- Happy Coding! Morten Wennevik [C# MVP]
- Next message: Morten Wennevik: "Re: Search in an Array"
- Previous message: carmen: "Re: close application after CreateProcess"
- In reply to: Gaia C via .NET 247: "Finding out a file encoding"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|