From 63df17f6ee8abfa7c819961e10ab710e3704c6f5 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Fri, 2 Jun 2023 11:43:16 +0100 Subject: [PATCH] [Import] DXF make codepage case insensitive See discussion https://forum.freecad.org/viewtopic.php?t=78719 I don't believe https://github.com/FreeCAD/FreeCAD/issues/8704 is fixed even after this change, the example file Encoding-error.dxf which can be opened by Varicad Viewer still opens error free but has nothing in the 3D view. --- src/Mod/Import/App/dxf/dxf.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Mod/Import/App/dxf/dxf.cpp b/src/Mod/Import/App/dxf/dxf.cpp index 5e6189b07a..62e93d7bc4 100644 --- a/src/Mod/Import/App/dxf/dxf.cpp +++ b/src/Mod/Import/App/dxf/dxf.cpp @@ -3342,8 +3342,11 @@ bool CDxfRead::ResolveEncoding() else { // Codepage names may be of the form "ansi_1252" which we map to "cp1252" but we don't map "ansi_x3xxxx" (which happens to mean "ascii") std::string* p = new std::string(*m_CodePage); - if (strncmp(p->c_str(), "ansi_", 5) == 0 - && strncmp(p->c_str(), "ansi_x3", 7) != 0) + std::string p_lower; + for (std::string::const_iterator i = p->begin(); i != p->end(); ++i) + p_lower += tolower(*i); + if (p_lower.substr(0, 5) == "ansi_" + && p_lower.substr(0, 7) != "ansi_x3") p->replace(0, 5, "cp"); m_encoding = p; // At this point we want to recognize synonyms for "utf_8" and use the custom decoder function.