From 1e63a61a4ee9c619ab416db901f153da8e08d10e Mon Sep 17 00:00:00 2001 From: abv Date: Sat, 24 Oct 2020 22:46:35 +0300 Subject: [PATCH] 0031113: Foundation Classes - TCollection_ExtendedString constructor from CString is confusing In constructor of TCollection_ExtendedString from Standard_CSTring (const char*), default value for the second argument (isMultiByte) is changed from False to True, for consistency with constructor from TCollection_AsciiString and adopted approach of using UTF-8 encoding for Unicode strings across OCCT. --- src/DDataStd/DDataStd_BasicCommands.cxx | 2 +- src/DDataStd/DDataStd_NameCommands.cxx | 2 +- src/TCollection/TCollection_ExtendedString.hxx | 15 ++++++++------- src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/DDataStd/DDataStd_BasicCommands.cxx b/src/DDataStd/DDataStd_BasicCommands.cxx index 6816f6a587..f9f0d05f0e 100644 --- a/src/DDataStd/DDataStd_BasicCommands.cxx +++ b/src/DDataStd/DDataStd_BasicCommands.cxx @@ -208,7 +208,7 @@ static Standard_Integer DDataStd_SetComment (Draw_Interpretor& di, if (!DDF::GetDF(arg[1],DF)) return 1; TDF_Label L; DDF::AddLabel(DF, arg[2], L); - TDataStd_Comment::Set(L,TCollection_ExtendedString(arg[3],Standard_True)); + TDataStd_Comment::Set(L,arg[3]); return 0; } di << "DDataStd_SetComment : Error\n"; diff --git a/src/DDataStd/DDataStd_NameCommands.cxx b/src/DDataStd/DDataStd_NameCommands.cxx index 321422749d..1895197f5d 100644 --- a/src/DDataStd/DDataStd_NameCommands.cxx +++ b/src/DDataStd/DDataStd_NameCommands.cxx @@ -64,7 +64,7 @@ static Standard_Integer DDataStd_SetName (Draw_Interpretor& di, return 1; } Standard_GUID guid(arg[4]); - TDataStd_Name::Set(L, guid, TCollection_ExtendedString(arg[3],Standard_True)); + TDataStd_Name::Set(L, guid, arg[3]); } return 0; } diff --git a/src/TCollection/TCollection_ExtendedString.hxx b/src/TCollection/TCollection_ExtendedString.hxx index 3e16ca49dc..dbdb3bd09f 100644 --- a/src/TCollection/TCollection_ExtendedString.hxx +++ b/src/TCollection/TCollection_ExtendedString.hxx @@ -63,13 +63,14 @@ public: //! Initializes a ExtendedString to an empty ExtendedString. Standard_EXPORT TCollection_ExtendedString(); - //! Creation by converting a CString to an extended - //! string. If is true then the string is - //! treated as having UTF-8 coding. If it is not a UTF-8 - //! then is ignored and each character is - //! copied to ExtCharacter. - Standard_EXPORT TCollection_ExtendedString(const Standard_CString astring, const Standard_Boolean isMultiByte = Standard_False); - + //! Creation by converting a plain C string to an extended string. + //! If @p isMultiByte is true then @p theString is treated as having UTF-8 encoding. + //! If @p isMultiByte is true but @p theString is not a valid UTF-8 string, + //! or if @p isMultiByte is false, then each character of @p theString is + //! copied to ExtCharacter (as if @p theString was in ISO 8859-1 code page). + Standard_EXPORT TCollection_ExtendedString(const Standard_CString theString, + const Standard_Boolean isMultiByte = Standard_True); + //! Creation by converting an ExtString to an extended string. Standard_EXPORT TCollection_ExtendedString(const Standard_ExtString astring); diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index 0eb954617b..3d8b497b4e 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -201,7 +201,7 @@ static Standard_Integer ReadGltf (Draw_Interpretor& theDI, else { Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc); - TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName.ToCString()); + TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName); Draw::Set (aDestName.ToCString(), aDrawDoc); } } @@ -604,7 +604,7 @@ static Standard_Integer ReadObj (Draw_Interpretor& theDI, else { Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc); - TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName.ToCString()); + TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName); Draw::Set (aDestName.ToCString(), aDrawDoc); } } -- 2.39.5