step-examples/12-6-assembly/P002.stp
Sources
- FreeCAD #7987, #22123
Sender
SolidWorks (Chinese-locale install) and any non-Western Windows export
Description
STEP-21 lines like `SHAPE_REPRESENTATION ('海绵2', ..)` appear in files encoded as GB18030 / Shift-JIS / CP1252 because exporters write the OS code page directly. Readers that assume UTF-8 produce mojibake in object labels and attributes; round-tripping then corrupts the saved project document.
Reproducer recipe
Generate a STEP file containing `PRODUCT`/`SHAPE_REPRESENTATION` name strings with high-bit bytes interpretable in GB18030 but not UTF-8 (or with the standard `\X2\…\X0\` Unicode escape sequences that exporters rarely emit).
Expected kernel behavior
Heal and accept: auto-detect or honor STEP-21 `\X2\` / `\X4\` escape sequences; expose a per-file encoding override; warn if bytes don't decode as declared encoding.
Notes
Synonyms: "GB18030 encoded part names corrupt after read", "non-UTF-8 string literals in STEP", "Chinese locale code page in name strings", "encoding mismatch garbles labels".
Expected validation
occt=shape(1)/shape(1) gmsh=shape(1) ifc=schema_n/a
Byte assertions
contains(b'\\X2\\') or matches(rb"[\x80-\xff]")
Tier-3 assertions
shape_null == Falsen_vertices_total == 1
Live oracle output
No live oracle data — run _run_corpus to populate.
Fixture content
Show fixture bytes
1ISO-10303-21; 2/* P002: NAUO name field carries \X2\ STEP-21 Unicode escapes for Chinese '海绵2'; additional PRODUCT entity uses raw Unicode (multi-byte UTF-8) to simulate GB18030 locale bytes written without \X2\ escaping; readers assuming UTF-8 pass-through produce mojibake in object labels; round-trip corrupts project document; GEOMETRIC_CURVE_SET IS model entity â OCC yields empty */ 3HEADER; 4FILE_DESCRIPTION(('P002'),'2;1'); 5FILE_NAME('P002.stp','2026-06-17T00:00:00',(''),(''),'cad-research-suite','',''); 6FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }')); 7ENDSEC; 8DATA; 9#9000=APPLICATION_CONTEXT('mechanical design'); 10#1=CARTESIAN_POINT('',(0.0,0.0,0.0)); 11#2=GEOMETRIC_CURVE_SET('',(#1)); 12#9050=PRODUCT_CONTEXT('',#9000,'mechanical'); 13#9051=PRODUCT('P002','P002','',(#9050)); 14#9052=PRODUCT_DEFINITION_FORMATION('','',#9051); 15#9053=PRODUCT_DEFINITION_CONTEXT('part definition',#9000,'design'); 16#9054=PRODUCT_DEFINITION('','','',#9052,#9053); 17#9055=PRODUCT_DEFINITION_SHAPE('','','',#9054); 18#9056=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.)); 19#9057=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.)); 20#9058=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT()); 21#9059=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.0E-7),#9056,'distance_accuracy_value',''); 22#9060=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#9059))GLOBAL_UNIT_ASSIGNED_CONTEXT((#9056,#9057,#9058))REPRESENTATION_CONTEXT('','3D')); 23#9061=MANIFOLD_SURFACE_SHAPE_REPRESENTATION('',(#2),#9060); 24#9062=SHAPE_DEFINITION_REPRESENTATION(#9055,#9061); 25#8998=NEXT_ASSEMBLY_USAGE_OCCURRENCE('1','\X2\6D77\X0\\X2\7EF5\X0\2','',#9054,$,$); 26#8999=PRODUCT('海绵2','sponge2','',(#9000)); 27 28ENDSEC; 29END-ISO-10303-21;