]> OCCT Git - occt.git/commitdiff
0031940: Foundation Classes - TCollection_ExtendedString::Print() corrupts UNICODE...
authorkgv <kgv@opencascade.com>
Wed, 18 Nov 2020 11:56:59 +0000 (14:56 +0300)
committerbugmaster <bugmaster@opencascade.com>
Sat, 28 Nov 2020 09:36:06 +0000 (12:36 +0300)
TCollection_ExtendedString::Print() now converts string into UTF-8
instead of printing character indexes.

dox/upgrade/upgrade.md
src/TCollection/TCollection_ExtendedString.cxx

index 34958e3bd6a08dc5f99a34f724db7be816127d90..f8221fc810bb56413d13a9b61d36777bdd08dc97 100644 (file)
@@ -2159,6 +2159,13 @@ Existing message files containing 8-bit characters (previously interpreted as ch
 
 @section upgrade_occt760 Upgrade to OCCT 7.6.0
 
+@subsection upgrade_760_extendedstring_cout Output of TCollection_ExtendedString to stream
+
+Behavior of the method TCollection_ExtendedString::Print(Standard_OStream&) and corresponding operator << has changed.
+Previously it printed all Latin-1 symbols (those in range 0x80-0xff) as '\0' (effectively loosing them); symbols above 0xff were converted to hex representation (formatted like XML Numeric Character Reference).
+Now all symbols are sent to stream as UTF-8 byte sequences.
+Existing code relying on old behavior, if any, shall be rewritten.
+
 @subsection upgrade_760_trimming_surface Trimming surface
 
 Geom_RectangularTrimmedSurface sequentially trimming in U and V directions already no longer loses the first trim.
index 00c60225ad51ef559b5e4df3f614802ab5156b2b..30597cb0ce463c7b05fede6c9221a610d00625e0 100644 (file)
@@ -611,16 +611,12 @@ Standard_Integer TCollection_ExtendedString::Length()  const
 // ----------------------------------------------------------------------------
 // Print
 // ----------------------------------------------------------------------------
-void TCollection_ExtendedString::Print(Standard_OStream& astream) const 
-{ 
-  // ASCII symbols (including extended Ascii) are printed as is;
-  // other Unicode characters are encoded as SGML numeric character references
-  for (Standard_Integer i = 0 ; i < mylength ; i++) {
-    Standard_ExtCharacter c = mystring[i];
-    if ( IsAnAscii(c) )
-      astream << ToCharacter(c);
-    else 
-      astream << "&#" << c << ";";
+void TCollection_ExtendedString::Print (Standard_OStream& theStream) const
+{
+  if (mylength > 0)
+  {
+    const TCollection_AsciiString aUtf8 (mystring);
+    theStream << aUtf8;
   }
 }