Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Unicode character in a maxon::String... how?

    Cinema 4D SDK
    c++
    2
    3
    339
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fwilleke80F
      fwilleke80
      last edited by

      Hi,

      a simple question this time... I hope.

      I need a maxon::String that looks like this:

      © 2021 by some awesome developer

      How can I get that copyright symbol in there?

      This can't be it:

      maxon::Utf32Char copyrightChar = 0x000000A9;
      maxon::String copyright;
      copyright.SetUtf32(&copyrightChar) iferr_ignore();
      maxon::String theActualString = copyright + " 2021 by some awesome developer"_s;
      

      It compiles, but using the resulting maxon::String in a GeDialogs static text element crashes when opening the dialog.

      There probably I something about this in the SDK docs, but I couldn't find it.

      Thanks in advance for help!

      Cheers,
      Frank

      www.frankwilleke.de
      Only asking personal code questions here.

      1 Reply Last reply Reply Quote 0
      • fwilleke80F
        fwilleke80
        last edited by fwilleke80

        Posting here always helps. Found nothing, until I made the post.

        Of course, it's simple:

        maxon::String copyright = "\u00A9 2021 by some awesome developer"_s;
        

        Cheers,
        Frank

        www.frankwilleke.de
        Only asking personal code questions here.

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          hi,

          thanks a lot for posting the answer.

          the problem in your first code is that SetUtf32 is that you didn't define your number of character. In the documentation, the count parameter is defined like so:

          Number of valid characters in the buffer. A count of -1 calculates the string length automatically, terminating when \0 is found

          3 solutions :

          // define the right character number
          copyright.SetUtf32(&copyrightChar, 1) iferr_return;
          
          // define an array of Utf32Char and initialise it
          maxon::Utf32Char copyrightP[2]{ 0x000000A9 , '\0' };
          
          // Create a buffer in memory
          maxon::Utf32Char* copyrightP = NewMemClear(Utf32Char, 2) iferr_return;
          	finally {
          		DeleteMem(copyrightP);
          	};
          	copyrightP[0] = 0x000000A9;
          	copyrightP[1] = '\0';
          

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 1
          • First post
            Last post