wchar_t on macos [SOLVED]

On 13/04/2017 at 06:19, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   18 
Platform:   Windows  ;   Mac OSX  ; 
Language(s) :     C++  ;


I'm using the pugi lib for dealing with XML files. The file methods require file paths in a wchar_t* buffer. On Windows I simple convert the string to a UInt16 buffer using GetUcBlock. But on macos this doesn't work. As far as I know, wchar_t is 32 bit on macos.

So is there anybody, who has already found a solution?

Thank you.

On 13/04/2017 at 10:12, xxxxxxxx wrote:

I guess this conversation on stackoverflow could help you http://stackoverflow.com/questions/9697203/convert-wchar-t-to-utf-16-string
 and this link http://unicode.org/faq/utf_bom.html#utf16-3

Can sound stupid but do you really need XML files? Cause json are really easy to implement https://github.com/open-source-parsers/jsoncpp and it can do quite same things.

On 13/04/2017 at 12:45, xxxxxxxx wrote:

thank you for replying.

Yes I need XML files because I want to support files that are already available.

And yes, I have already googled and found some info like your tips. But I don't need to convert to UTF-16. I need to convert from 16 Bit strings to 32 bit strings.

I solved the problem now by inserting this dowdy piece of code. The advantage is, that it certainly also works in Windows (although it's useless) so I can use the same code on both platforms.

UInt16 filename[512];   
fn.GetString().GetUcBlockNull(filename, 511);   
wchar_t file[512];   
Int32 i;   
for (i = 0; i<512; i++)   
    file[i] = filename[i];     // expand to 32 bit chars on macos   
pugi::xml_parse_result result = xmldoc.load_file(file);   

Btw: pugi is a really nice XML parser and exporter.

On 18/04/2017 at 08:58, xxxxxxxx wrote:

Hi Klaus, thanks for writing us.

With reference to your first post, I wonder if you were referring to a different Cinema release rather than R18 since the methods you were referring and using have been removed since R17. From R17.032 similar functionalities are brought by String::GetUtf16() and String::GetUtf32().

Best, Riccardo