From 82c96b84d39e24c9fec476684566e1739dd03020 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Fri, 23 Oct 2026 13:20:08 +0200 Subject: [PATCH] Wire numbers CSV export: write a UTF-8 BOM and drop stray pointer line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the Qt6 port QTextStream always writes UTF-8 (Qt5 used the locale codec, ANSI on Windows). Without a BOM Excel opens the file as ANSI, so any non-ASCII character in a wire number is mangled, e.g. an en dash prefix "–010" becomes "–010" (forum topic 3221). Write a BOM, as the parts list export already does. Also `stream << &Qt::endl(stream)` streamed the address of the stream, adding a bogus last line like "0xa78cffb090"; wiresNum() already terminates every line, so just drop it. --- sources/conductornumexport.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/conductornumexport.cpp b/sources/conductornumexport.cpp index ea43be511..8c6dc214a 100644 --- a/sources/conductornumexport.cpp +++ b/sources/conductornumexport.cpp @@ -27,6 +27,7 @@ #include "properties/elementdata.h" #include +#include /** @brief ConductorNumExport::ConductorNumExport @@ -73,8 +74,14 @@ bool ConductorNumExport::toCsv() if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream stream(&file); - - stream << wiresNum() << &Qt::endl(stream); + //Qt6 writes UTF-8 by default; without a BOM Excel reads + //the file as ANSI and mangles any non-ASCII character of + //a wire number (e.g. "–010" shown as "–010"). + //Same as the parts list export (BomExport). + stream.setEncoding(QStringConverter::Utf8); + stream.setGenerateByteOrderMark(true); + //wiresNum() already ends each line with "\n" + stream << wiresNum(); } else { return false;