Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

wchar_t on macos [SOLVED]

 Post Reply Post Reply
Author
Message
Klaus Heyne View Drop Down
Member
Member
Avatar

Joined: 2003 Jan 28
Location: Germany
Online Status: Offline
Posts: 279
Post Options Post Options   Quote Klaus Heyne Quote  Post ReplyReply Direct Link To This Post Topic: wchar_t on macos [SOLVED]
    Posted: 2017 Apr 13 at 6:19am

User Information:

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

---------

Hi,

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.
Back to Top
gr4ph0s View Drop Down
Member
Member


Joined: 2015 Jul 07
Location: Nantes
Online Status: Offline
Posts: 270
Post Options Post Options   Quote gr4ph0s Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Apr 13 at 10:12am
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.


Edited by gr4ph0s - 2017 Apr 13 at 10:40am
Back to Top
Klaus Heyne View Drop Down
Member
Member
Avatar

Joined: 2003 Jan 28
Location: Germany
Online Status: Offline
Posts: 279
Post Options Post Options   Quote Klaus Heyne Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Apr 13 at 12:45pm
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.

Back to Top
knickknack View Drop Down
Forum Moderator
Forum Moderator


Joined: 2016 Jul 01
Location: Italy
Online Status: Offline
Posts: 118
Post Options Post Options   Quote knickknack Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Apr 18 at 8:58am
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
MAXON Computer GmbH
SDK Support Team
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.