1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0028454: Data Exchange, STEP reader - names with special characters cannot be read

- Add support of the control directives ( "\X2\" "\X4" "\X\" "\P*\" "\S\");
- Make param "read.stepcaf.codepage" base for conversion inside StepData instead of CAF;
- Rename "read.stepcaf.codepage" to "read.step.codepage".
- Add ISO 8859-1 - 9 code pages for conversion
- Add Resource_FormatType_NoConversion format type, that indicates non-conversion behavior
- Update old test cases that contain control directives
This commit is contained in:
dpasukhi
2020-10-09 13:57:30 +03:00
committed by bugmaster
parent 380748c340
commit 1b9cb073b9
22 changed files with 949 additions and 89 deletions

View File

@@ -69,26 +69,5 @@ Standard_Boolean STEPCAFControl_Controller::Init ()
Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "eval On"); // 1
Interface_Static::SetIVal("read.stepcaf.subshapes.name", 0); // Disabled by default
// STEP file encoding for names translation
// Note: the numbers should be consistent with Resource_FormatType enumeration
Interface_Static::Init ("step", "read.stepcaf.codepage", 'e', "");
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "enum 0");
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval SJIS"); // Resource_FormatType_SJIS
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval EUC"); // Resource_FormatType_EUC
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval ANSI"); // Resource_FormatType_ANSI
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval GB"); // Resource_FormatType_GB
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval UTF8"); // Resource_FormatType_UTF8
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval SystemLocale"); // Resource_FormatType_SystemLocale
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1250"); // Resource_FormatType_CP1250
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1251"); // Resource_FormatType_CP1251
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1252"); // Resource_FormatType_CP1252
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1253"); // Resource_FormatType_CP1253
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1254"); // Resource_FormatType_CP1254
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1255"); // Resource_FormatType_CP1255
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1256"); // Resource_FormatType_CP1256
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1257"); // Resource_FormatType_CP1257
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval CP1258"); // Resource_FormatType_CP1258
Interface_Static::SetCVal ("read.stepcaf.codepage", "UTF8");
return Standard_True;
}

View File

@@ -281,7 +281,6 @@
#include <Transfer_ActorOfTransientProcess.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <Resource_Unicode.hxx>
// skl 21.08.2003 for reading G&DT
//#include <StepRepr_CompoundItemDefinition.hxx>
@@ -321,8 +320,7 @@ TCollection_AsciiString AddrToString(const TopoDS_Shape& theShape)
//=======================================================================
STEPCAFControl_Reader::STEPCAFControl_Reader()
: mySourceCodePage (Resource_FormatType_UTF8),
myColorMode(Standard_True),
: myColorMode(Standard_True),
myNameMode(Standard_True),
myLayerMode(Standard_True),
myPropsMode(Standard_True),
@@ -332,7 +330,6 @@ STEPCAFControl_Reader::STEPCAFControl_Reader()
myViewMode(Standard_True)
{
STEPCAFControl_Controller::Init();
mySourceCodePage = (Resource_FormatType )Interface_Static::IVal ("read.stepcaf.codepage");
}
@@ -343,8 +340,7 @@ STEPCAFControl_Reader::STEPCAFControl_Reader()
STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& WS,
const Standard_Boolean scratch)
: mySourceCodePage (Resource_FormatType_UTF8),
myColorMode(Standard_True),
: myColorMode(Standard_True),
myNameMode(Standard_True),
myLayerMode(Standard_True),
myPropsMode(Standard_True),
@@ -354,7 +350,6 @@ STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)
myViewMode(Standard_True)
{
STEPCAFControl_Controller::Init();
mySourceCodePage = (Resource_FormatType )Interface_Static::IVal ("read.stepcaf.codepage");
Init(WS, scratch);
}
@@ -386,9 +381,10 @@ void STEPCAFControl_Reader::Init(const Handle(XSControl_WorkSession)& WS,
//=======================================================================
TCollection_ExtendedString STEPCAFControl_Reader::convertName (const TCollection_AsciiString& theName) const
{
TCollection_ExtendedString aName;
Resource_Unicode::ConvertFormatToUnicode (mySourceCodePage, theName.ToCString(), aName);
return aName;
// If source code page is not a NoConversion
// the string is treated as having UTF-8 coding,
// else each character is copied to ExtCharacter.
return TCollection_ExtendedString (theName, SourceCodePage() != Resource_FormatType_NoConversion);
}
//=======================================================================
@@ -4787,6 +4783,26 @@ Standard_Boolean STEPCAFControl_Reader::GetNameMode() const
return myNameMode;
}
//=======================================================================
//function : SourceCodePage
//purpose :
//=======================================================================
Resource_FormatType STEPCAFControl_Reader::SourceCodePage() const
{
return myReader.StepModel()->SourceCodePage();
}
//=======================================================================
//function : SetSourceCodePage
//purpose :
//=======================================================================
void STEPCAFControl_Reader::SetSourceCodePage(Resource_FormatType theCode)
{
myReader.StepModel()->SetSourceCodePage(theCode);
}
//=======================================================================
//function : SetLayerMode
//purpose :

View File

@@ -142,11 +142,11 @@ public:
Standard_EXPORT Standard_Boolean GetNameMode() const;
//! Return the encoding of STEP file for converting names into UNICODE.
//! Initialized from "read.stepcaf.codepage" variable by constructor, which is Resource_UTF8 by default.
Resource_FormatType SourceCodePage() const { return mySourceCodePage; }
//! Initialized from "read.step.codepage" variable by constructor, which is Resource_UTF8 by default.
Standard_EXPORT Resource_FormatType SourceCodePage() const;
//! Return the encoding of STEP file for converting names into UNICODE.
void SetSourceCodePage (Resource_FormatType theCode) { mySourceCodePage = theCode; }
Standard_EXPORT void SetSourceCodePage (Resource_FormatType theCode);
//! Set LayerMode for indicate read Layers or not.
Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
@@ -301,7 +301,6 @@ private:
STEPControl_Reader myReader;
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
Resource_FormatType mySourceCodePage;
Standard_Boolean myColorMode;
Standard_Boolean myNameMode;
Standard_Boolean myLayerMode;