[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.
This commit is contained in:
Syres916
2023-06-02 11:43:16 +01:00
committed by GitHub
parent 5f20ee2663
commit 63df17f6ee

View File

@@ -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.