0022484: UNICODE characters support

Initial UNICODE (UFT-8) characters support for OCCT file operations

Fix for compilation errors and fix for StepFile (avoid objects in pure c code)

Fixes for set unicode symbols to OCAF and visualization
This commit is contained in:
pdn
2014-10-02 15:39:25 +04:00
committed by bugmaster
parent d3dfddaebc
commit d9ff84e8ea
34 changed files with 617 additions and 510 deletions

View File

@@ -35,10 +35,11 @@ Standard_EXPORT short NULL_EXTSTRING[1] = {0};
inline Standard_ExtCharacter ConvertToUnicode2B (unsigned char *p)
{
// *p, *(p+1)
// little endian
union {
struct {
unsigned char h;
unsigned char l;
unsigned char h;
} hl;
Standard_ExtCharacter chr;
} EL;
@@ -61,10 +62,11 @@ inline Standard_ExtCharacter ConvertToUnicode2B (unsigned char *p)
inline Standard_ExtCharacter ConvertToUnicode3B (unsigned char *p)
{
// *p, *(p+1), *(p+2) =>0 , 1, 2
// little endian
union {
struct {
unsigned char h;
unsigned char l;
unsigned char h;
} hl;
Standard_ExtCharacter chr;
} EL;
@@ -143,9 +145,11 @@ TCollection_ExtendedString::TCollection_ExtendedString
mystring = Allocate( (mylength+1)*2 );
if(!ConvertToUnicode (astring))
{
#ifdef DEB
cout <<"UTF8 decoding failure..." <<endl;
#endif
mylength = (int)strlen( astring );
mystring = Reallocate(mystring, (mylength+1)*2);
for (int i = 0 ; i < mylength ; i++)
mystring[i] = ToExtCharacter(astring[i]);
mystring[mylength] = '\0';
}
}
}
@@ -268,11 +272,16 @@ TCollection_ExtendedString::TCollection_ExtendedString
TCollection_ExtendedString::TCollection_ExtendedString
(const TCollection_AsciiString& astring)
{
mylength = astring.Length();
mylength = nbSymbols(astring.ToCString());
mystring = Allocate((mylength+1)*2);
Standard_CString aCString = astring.ToCString() ;
for (Standard_Integer i = 0; i <= mylength ; i++)
mystring[i] = ToExtCharacter( aCString[i] );
if(!ConvertToUnicode (astring.ToCString()))
{
mylength = astring.Length();
mystring = Reallocate(mystring, (mylength+1)*2);
Standard_CString aCString = astring.ToCString();
for (Standard_Integer i = 0; i <= mylength ; i++)
mystring[i] = ToExtCharacter( aCString[i] );
}
}
// ----------------------------------------------------------------------------