Beispiel #1
0
        /// <summary>
        /// Tries to detect the file encoding.
        /// </summary>
        /// <param name="inputData">The input data.</param>
        /// <param name="start">The start.</param>
        /// <param name="count">The count.</param>
        /// <param name="defaultIfNotDetected">The default encoding if none was detected.</param>
        /// <returns></returns>
        public static Encoding DetectFileEncoding(byte[] inputData, int start, int count, Encoding defaultIfNotDetected = null)
        {
            var det = new EncodingUtil();

            det.Detect(inputData, start, count);
            return(det.Complete() ?? defaultIfNotDetected);
        }
Beispiel #2
0
        /// <summary>
        /// Tries to detect the file encoding.
        /// </summary>
        /// <param name="inputStream">The input stream.</param>
        /// <param name="defaultIfNotDetected">The default encoding if none was detected.</param>
        /// <returns></returns>
        public static Encoding DetectFileEncoding(Stream inputStream, Encoding defaultIfNotDetected = null)
        {
            var det = new EncodingUtil();

            det.Detect(inputStream);
            return(det.Complete() ?? defaultIfNotDetected);
        }
Beispiel #3
0
 /// <summary>
 /// Tries to detect the file encoding.
 /// </summary>
 /// <param name="inputData">The input data.</param>
 /// <param name="start">The start.</param>
 /// <param name="count">The count.</param>
 /// <param name="defaultIfNotDetected">The default encoding if none was detected.</param>
 /// <returns></returns>
 public static Encoding DetectFileEncoding (byte[] inputData, int start, int count, Encoding defaultIfNotDetected = null)
 {
     var det = new EncodingUtil ();
     det.Detect (inputData, start, count);
     return det.Complete () ?? defaultIfNotDetected;            
 }
Beispiel #4
0
 /// <summary>
 /// Tries to detect the file encoding.
 /// </summary>
 /// <param name="inputStream">The input stream.</param>
 /// <param name="defaultIfNotDetected">The default encoding if none was detected.</param>
 /// <returns></returns>
 public static Encoding DetectFileEncoding (Stream inputStream, Encoding defaultIfNotDetected = null)
 {
     var det = new EncodingUtil ();
     det.Detect (inputStream);
     return det.Complete () ?? defaultIfNotDetected;
 }