diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 708c6ef1b..0e7542038 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -109,7 +110,8 @@ bool VDxfEngine::begin(QPaintDevice *pdev) return false; } - input = QSharedPointer(new dx_iface(fileName.toStdString(), m_version, varMeasurement, varInsunits)); + input = QSharedPointer(new dx_iface(getFileNameForLocale(), m_version, varMeasurement, + varInsunits)); input->AddQtLTypes(); input->AddDefLayers(); return true; @@ -611,7 +613,8 @@ bool VDxfEngine::ExportToAAMA(const QVector &details) return false; } - input = QSharedPointer(new dx_iface(fileName.toStdString(), m_version, varMeasurement, varInsunits)); + input = QSharedPointer(new dx_iface(getFileNameForLocale(), m_version, varMeasurement, + varInsunits)); input->AddAAMAHeaderData(); if (m_version > DRW::AC1009) { @@ -849,6 +852,28 @@ DRW_Entity *VDxfEngine::AAMAText(const QPointF &pos, const QString &text, const return textLine; } +//--------------------------------------------------------------------------------------------------------------------- +std::string VDxfEngine::FromUnicodeToCodec(const QString &str, QTextCodec *codec) +{ + const QByteArray encodedString = codec->fromUnicode(str); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) + return encodedString.toStdString(); +#else + return std::string(encodedString.constData(), static_cast(encodedString.length())); +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +std::string VDxfEngine::getFileNameForLocale() const +{ +#if defined(Q_OS_WIN) + return VDxfEngine::FromUnicodeToCodec(fileName, QTextCodec::codecForLocale()); +#else + return fileName.toStdString(); +#endif +} + //--------------------------------------------------------------------------------------------------------------------- template P *VDxfEngine::CreateAAMAPolygon(const QVector &polygon, const QString &layer, bool forceClosed) diff --git a/src/libs/vdxf/vdxfengine.h b/src/libs/vdxf/vdxfengine.h index 414d9bf82..f6b266c05 100644 --- a/src/libs/vdxf/vdxfengine.h +++ b/src/libs/vdxf/vdxfengine.h @@ -124,6 +124,9 @@ private: template Q_REQUIRED_RESULT P *CreateAAMAPolygon(const QVector &polygon, const QString &layer, bool forceClosed); + + static std::string FromUnicodeToCodec(const QString &str, QTextCodec *codec); + std::string getFileNameForLocale() const; }; #endif // VDXFENGINE_H