Wire numbers CSV export: write a UTF-8 BOM and drop stray pointer line

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.
This commit is contained in:
Laurent Trinques
2026-10-23 13:20:08 +02:00
parent f68927d0a4
commit 82c96b84d3
+9 -2
View File
@@ -27,6 +27,7 @@
#include "properties/elementdata.h"
#include <QFileDialog>
#include <QTextStream>
/**
@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;