1

When I'm reading a TXT file with "special" characters it works perfectly fine. But when I read a DXF file, it translates it to the wrong characters (see image below).

is the iso-8859-1 not the correct encoding for DXF files? R

6
  • 2
    I strongly suspect it's UTF-8. Have you tried that? See also: ezdxf.readthedocs.io/en/master/dxfinternals/fileencoding.html
    – Jon Skeet
    Feb 20, 2020 at 14:57
  • Also note "When I'm reading a TXT file with "special" characters it works perfectly fine" - well that depends on which encoding was used to write the text file.
    – Jon Skeet
    Feb 20, 2020 at 14:58
  • @jonSkeet I created the file myself for testing with notepad
    – Bart
    Feb 20, 2020 at 15:02
  • 1
    Right. But Notepad has multiple options for which encoding to use. Presumably you happened to use one that's compatible with ISO-8859-1. But plain text files can use any encoding - you shouldn't assume that every file with a .txt extension uses ISO-8859-1.
    – Jon Skeet
    Feb 20, 2020 at 15:04
  • Yea it's UTF-8. If you give an answer I can set it as answered. How can Is there a way to check a files encoding?
    – Bart
    Feb 20, 2020 at 15:06

1 Answer 1

2

According to this documentation, DXF files have been written using UTF-8 since DXF R2007. This makes them much more portable than depending on a specific code page.

That's also the default for File.ReadAllLines, so you can just use File.ReadAllLines(FileName).

1
  • Yea that's it! Thanks for your help!
    – Bart
    Feb 20, 2020 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.