Unicode character in a maxon::String... how?
-
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(©rightChar) iferr_ignore(); maxon::String theActualString = copyright + " 2021 by some awesome developer"_s;
It compiles, but using the resulting
maxon::String
in aGeDialog
s 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 -
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 -
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(©rightChar, 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