DiscussionsIssue archiveOCCT:Application Framework

Archived issue #0029219

Application Framework - XML document is written with CRLF on Windows

Open CASCADEOCCT:Application Frameworkclosed13 public notes

Search issues

Description

It seems that XML document has different EOL depending on the platform - CRLF on Windows and LF on other systems. Most likely, it is due to std::ofstream being opened in text mode instead of binary mode.

It would be useful saving XML files in consistent way across systems - e.g. using LF instead of CRLF on Windows (this would also reduce file size a little).

Steps to reproduce

A set of small scripts are attached. They produce a small file of the considered file format.

Public activity

13 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Windows end-of-lines for text files is standard. XML is a text file. We cannot simply change it in OCCT.
02Author
OK, the issue is not specific to XML export - BREP/STEP/IGES are also written with CRLF on Windows. However, behavior is still questionable:
- OCCT XML:    CRLF
- OCCT BREP:   CRLF
- OCCT STEP:   CRLF
- OCCT IGES:   CRLF
- OCCT VRML:   CRLF
- OCCT STL:    LF
- Blender X3D: CRLF
- Blender STL: CRLF
- Blender OBJ: LF
- Blender PLY: LF
- RPly:        LF
03Commenter 1
I checked a STL file of Open CASCADE in ASCII format on Windows - it ends by CRLF. In Open CASCADE it writes by _wfopen (filename, "w") Windows API function.
Also, I checked Blender OBJ: it uses the same _wfopen (filename, "wb"), but in binary mode (additional 'b' is used) - it ends by LF.

So, I suppose all writers of Open CASCADE should end by CR LF on Windows, am I right?
04Author
> So, I suppose all writers of Open CASCADE should end by CR LF on Windows, am I right?

I propose all OCCT writers to output LF endlines on all platforms, when this is allowed by file format specification.
05Commenter 3
Branch [archived branch] has been created by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Mon Feb 21 10:41:05 2022 +0300

    0029219: Application Framework - XML document is written with CRLF on Windows
    
    The last symbol of a line is synchronized with external products.
    Also, XML ends by LF now.
    
    Modified:
    XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
    BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
    STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
    IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
    VRML: VrmlAPI_Writer::write_v2() ends by LF
    STL: RWStl::WriteAscii() ends by CR LF (to synchronize with Blender)
06Commenter 1
Short scripts are added to generate the corresponding files:
XML
BREP
STEP
IGES
STL
VRML
occt_brep (43 bytes)   
occt_iges (50 bytes)   
occt_step (50 bytes)   
occt_stl (61 bytes)   
occt_vrml (61 bytes)   
occt_xml (46 bytes)   
07Commenter 1
Dear Mikhail, could you revise the fix, pease?
The branch: [archived branch] - CR29219.
Result of compilation and testing: http://jenkins-test-08.nnov.opencascade.com/view/CR29219-master-VRO/view/COMPARE/ (as usual, Open GL driver for D3D failed, and a test on performance failed, but this test doesn't involve any write-operations - we might ignore these instabilities).

The following change were done:
XML - ends by LF
BREP - ends by LF
STEP - ends by LF
IGES - ends by LF
STL - ends by CR LF
VRML - ends by LF

Also, considered DXF files stored by AutoCAD. They end by CR LF like OCCT does - no changes.
08Author
> STL: RWStl::WriteAscii() ends by CR LF (to synchronize with Blender)

I guess this comment is irrelevant to the current patch and could be removed from git commit description (no changes done to STL writer).
09Commenter 3
Branch [archived branch] has been updated by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Mon Feb 21 15:13:35 2022 +0300

    0029219: Application Framework - XML document is written with CRLF on Windows
    
    The last symbol of a line is synchronized with external products.
    Also, XML ends by LF now.
    
    Modified:
    XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
    BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
    STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
    IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
    VRML: VrmlAPI_Writer::write_v2() ends by LF

Author: Commenter 1
Date: Mon Feb 21 15:12:40 2022 +0300

    Merge branch 'CR29219' of git.dev.opencascade.org:occt into CR29219

Author: Commenter 1
Date: Mon Feb 21 10:41:05 2022 +0300

    0029219: Application Framework - XML document is written with CRLF on Windows
    
    The last symbol of a line is synchronized with external products.
    Also, XML ends by LF now.
    
    Modified:
    XML: XmlLDrivers_DocumentStorageDriver::Write() ends by LF
    BREP: BRepTools::Write(), Draw_VariableCommands::save() ends by LF
    STEP: StepSelect_WorkLibrary::WriteFile() ends by LF
    IGES: IGESSelect_WorkLibrary::WriteFile(), IGESControl_Writer::Write(), XSDRAWIGES::WriteShape() ends by LF
    VRML: VrmlAPI_Writer::write_v2() ends by LF
10Commenter 1
The message for the last commit is corrected.
11Commenter 11
Reviewed
OCCT: CR32785_2
PRODUCTS: None
12Commenter 12
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18467.180000000375 / 18497.380000000365 [-0.16%]
Products
Total CPU difference: 11716.630000000077 / 11705.020000000135 [+0.10%]
Windows-64-VC14:
OCCT
Total CPU difference: 20359.046875 / 20453.9375 [-0.46%]
Products
Total CPU difference: 13140.734375 / 13176.3125 [-0.27%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
13Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]

Related records