fix: repair double-encoded degree symbol in DXF output

ACadSharp misreads UTF-8 degree symbol (C2 B0) as two ANSI_1252
characters (°) then writes that back out. Post-process the saved
DXF to replace ° with ° so bend notes display correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 16:31:57 -05:00
parent 622cbf1170
commit f9e7ace35d
2 changed files with 16 additions and 1 deletions

View File

@@ -307,6 +307,7 @@ namespace ExportDXF.Services
{
var etcher = new EtchBendLines.Etcher();
etcher.AddEtchLines(dxfPath);
FixDegreeSymbol(dxfPath);
}
catch (Exception)
{
@@ -314,6 +315,20 @@ namespace ExportDXF.Services
}
}
/// <summary>
/// ACadSharp misreads the UTF-8 degree symbol (C2 B0) as two ANSI_1252
/// characters (°). Fix it in the written DXF so bend notes display correctly.
/// </summary>
private static void FixDegreeSymbol(string path)
{
var text = System.IO.File.ReadAllText(path);
if (text.Contains("\u00C2\u00B0"))
{
text = text.Replace("\u00C2\u00B0", "\u00B0");
System.IO.File.WriteAllText(path, text);
}
}
private string GetSinglePartFileName(ModelDoc2 model, string prefix)
{
var title = model.GetTitle().Replace(".SLDPRT", "");