Skip to content

GetFileEncoding Method ​

Definition ​

  • Namespace: JASE.IO
  • Assembly: JASE.dll

Overloads ​

NameDescription
Encoding GetFileEncoding(Stream stream)Attempts to detect the text encoding of a file from a stream by inspecting its initial bytes.
Encoding GetFileEncoding(string filename)Attempts to detect the text encoding of the specified file.

Encoding GetFileEncoding(Stream stream) ​

csharp
Encoding GetFileEncoding(Stream stream)

Attempts to detect the text encoding of a file from a stream by inspecting its initial bytes.

Parameters ​

NameDescription
streamThe stream to examine. The current position is preserved.

Returns ​

The detected encoding, or a default encoding if the encoding cannot be determined.

Encoding GetFileEncoding(string filename) ​

csharp
Encoding GetFileEncoding(string filename)

Attempts to detect the text encoding of the specified file.

Parameters ​

NameDescription
filenameThe path to the file to examine.

Returns ​

The detected encoding, or a default encoding if the encoding cannot be determined.