< Summary

Information
Class: ValidateLib.Encoding.Detection.EncodingDetector
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Encoding\Detection\EncodingDetector.cs
Line coverage
75%
Covered lines: 3
Uncovered lines: 1
Coverable lines: 4
Total lines: 24
Line coverage: 75%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBlocks covered Blocks not covered
IsUtf8(...)92

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Encoding\Detection\EncodingDetector.cs

#LineLine coverage
 1using UtfUnknown;
 2
 3namespace ValidateLib.Encoding.Detection
 4{
 5    /// <summary>
 6    /// Detects different types of encoding in a file.
 7    /// </summary>
 8    public class EncodingDetector
 9    {
 10        /// <summary>
 11        /// Checks whether a file is encoded in utf8.
 12        /// </summary>
 13        /// <param name="filePath"> Path to a file. </param>
 14        /// <returns> True if the file is encoded in utf8, false otherwise.</returns>
 15        public static bool IsUtf8(string filePath)
 16        {
 117            DetectionResult result = CharsetDetector.DetectFromFile(filePath);
 118            DetectionDetail resultDetected = result.Detected;
 119            var resultx = resultDetected != null ? resultDetected.EncodingName == "utf-8" || resultDetected.EncodingName
 020            return resultx;
 21        }
 22
 23    }
 24}

Methods/Properties

IsUtf8(string)