Archicad C++ API
About Archicad add-on development using the C++ API.

CHANSI2Unicode doc

Tomasz Marek
Beginner
Hi,

There are few mistakes in the documentation of CHANSI2Unicode.
    long CHANSI2Unicode (
      const char*  pChars,                    // string to convert
      long         nChars,                    // number of bytes in string
      wchar_t*     pWChars,                   // wide-char buffer
      long         maxWChars,                 // wide char buffer length
      GSCharCode   charCode = CC_Default        // Character codepage of input
      CHANIS2UnicodeCacheRef*  cache = NULL           // can be used to cache conversion result, if called twice
    );
First of all pWChars is not wchar_t* , but uchar_t* (unsigned short).

There is no way to get the example work as it is right now (R16.0).
GS::ANIS2UnicodeCacheRef cache = 0;
Should read GS::CHANSI2UnicodeCacheRef.
p variable type is not defined.

What is a proper way to convert a material name (const char*) to UTF8?
I cannot get CC_UTF8 it to work (x64 Win).

Thanks
Tomasz
2 REPLIES 2
Ralph Wessel
Mentor
Tomasz wrote:
What is a proper way to convert a material name (const char*) to UTF8?
I cannot get CC_UTF8 it to work (x64 Win).
Try converting to Unicode first (CHANSI2Unicode) and then from Unicode to UTF8 (CHUnicode2ANSI).
Ralph Wessel BArch
Software Engineer Speckle Systems
Tomasz Marek
Beginner
Ralph wrote:
Try converting to Unicode first (CHANSI2Unicode) and then from Unicode to UTF8 (CHUnicode2ANSI).
It did the trick.
I was wondering how they want to push char* into uchar_t*...

Thanks!