1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0014673: Provide true support for Unicode symbols

Construction of TCollection_ExtendedString from plain C string is fixed to consider input string as UTF-8 in several places (identified as described in notes to #31113).

Message_MsgFile is corrected to load resource file as UTF-8 (unless it has BOM indicating use of UTF-16).

Added tests for use of Unicode in some DRAW commands (bugs demo bug14673_*)
This commit is contained in:
abv
2020-10-25 22:10:27 +03:00
committed by bugmaster
parent aa7e9f8d78
commit 94f16a8961
17 changed files with 177 additions and 48 deletions

View File

@@ -82,13 +82,17 @@ Standard_Boolean Message_MsgFile::Load (const Standard_CString theDirName,
//Called : from loadFile()
//=======================================================================
template <class _Char> static inline Standard_Boolean
getString (_Char *& thePtr,
template <typename CharType> struct TCollection_String;
template <> struct TCollection_String <Standard_Character> { typedef TCollection_AsciiString type; };
template <> struct TCollection_String <Standard_ExtCharacter> { typedef TCollection_ExtendedString type; };
template <class CharType> static inline Standard_Boolean
getString (CharType *& thePtr,
TCollection_ExtendedString& theString,
Standard_Integer& theLeftSpaces)
{
_Char * anEndPtr = thePtr;
_Char * aPtr;
CharType * anEndPtr = thePtr;
CharType * aPtr;
Standard_Integer aLeftSpaces;
do
@@ -98,7 +102,7 @@ getString (_Char *& thePtr,
aLeftSpaces = 0;
for (;;)
{
_Char aChar = * aPtr;
CharType aChar = * aPtr;
if (aChar == ' ') aLeftSpaces++;
else if (aChar == '\t') aLeftSpaces += 8;
else if (aChar == '\r' || * aPtr == '\n') aLeftSpaces = 0;
@@ -121,7 +125,7 @@ getString (_Char *& thePtr,
thePtr = anEndPtr;
if (*thePtr)
*thePtr++ = '\0';
theString = TCollection_ExtendedString (aPtr);
theString = typename TCollection_String<CharType>::type (aPtr);
theLeftSpaces = aLeftSpaces;
return Standard_True;
}