-
Notifications
You must be signed in to change notification settings - Fork 49
Object reference not set to an instance of an object. #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
// Detect from File (NET standard 1.3+ or .NET 4+)
DetectionResult result = CharsetDetector.DetectFromFile("path/to/file.txt"); // or pass FileInfo Maybe it also fails for other methods which accept strings/streams. |
Please share a full stracktrace, thanks! |
I verified detection on empty file/stream/bytes and it works as expected: [Test]
public void CharsetDetector_EmptyStreamDetection_DetectedShouldBeNull()
{
const string emptyFile = "empty.txt";
File.Create(emptyFile).Dispose();
Assert.IsNull(CharsetDetector.DetectFromFile(emptyFile).Detected);
Assert.IsNull(CharsetDetector.DetectFromStream(File.Open(emptyFile, FileMode.Open)).Detected);
Assert.IsNull(CharsetDetector.DetectFromBytes(Array.Empty<byte>()).Detected);
} @MIMAXUZ It means that encoding detection failed for your file - in this case |
Thanks for the confirm @i2van Indeed, Detected could be The code in the start:
Could indeed throw an exception recommend usage:
|
Uh oh!
There was an error while loading. Please reload this page.
I have several files and I can read them in own ecnoding format. But there is a problem reading a single file. I read the file by determining which codePage contains the information in the file.
I have the following code:
Error:
But no other file had such a problem. When I open the file via notepad, Encoding shows ANSI.
The file is not empty, and contains mostly texts in the Cyrillic alphabet. I taught in 1251, UTF-8 format but ???? character is changing.
How can the problem be solved? Thank you!
The text was updated successfully, but these errors were encountered: