diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp index eb8910a26a..be67fe88d5 100644 --- a/common/dialogs/wx_html_report_panel.cpp +++ b/common/dialogs/wx_html_report_panel.cpp @@ -26,6 +26,7 @@ #include #include #include +#include WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id, @@ -343,7 +344,10 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event ) for( const REPORT_LINE& l : m_report ) { - f.Write( generatePlainText( l ) ); + wxString s = generatePlainText( l ); + + ConvertSmartQuotesAndDashes( &s ); + f.Write( s ); } m_ReportFileName = fn.GetFullPath(); f.Close(); diff --git a/common/string.cpp b/common/string.cpp index bafc0abae5..b468da163a 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -40,6 +40,33 @@ static const char illegalFileNameChars[] = "\\/:\"<>|"; +bool ConvertSmartQuotesAndDashes( wxString* aString ) +{ + bool retVal = false; + + for( wxString::iterator ii = aString->begin(); ii != aString->end(); ++ii ) + { + if( *ii == L'\u0060' || *ii == L'\u00B4' || *ii == L'\u2018' || *ii == L'\u2019' ) + { + *ii = '\''; + retVal = true; + } + if( *ii == L'\u201C' || *ii == L'\u201D' ) + { + *ii = '"'; + retVal = true; + } + if( *ii == L'\u2013' || *ii == L'\u2014' ) + { + *ii = '-'; + retVal = true; + } + } + + return retVal; +} + + /** * These Escape/Unescape routines use HTML-entity-reference-style encoding to handle * characters which are: diff --git a/include/kicad_string.h b/include/kicad_string.h index 692ec505b6..3cdbb6da79 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -38,6 +38,13 @@ #include +/** + * Converts curly quotes and em/en dashes to straight quotes and dashes. + * @param aString + * @return true if any characters required conversion. + */ +bool ConvertSmartQuotesAndDashes( wxString* aString ); + /** * Escape/Unescape routines to safely encode reserved-characters in various * contexts.