Connect with users of Wolfram technologies to learn, solve problems and share ideas
Mark as an Answer
3 Total Likes
Follow this post
Share this post:
External Programs and Systems
Does MLGetUTF8String() return a null-terminated string?
11 years ago
The C MathLink function MLGetUTF8String() returns a pointer to a UTF-8 string, the length of the string and the number of characters. UTF-8 is desgined in a way to be compatible with null-terminated strings, and it appears that this function does return a null-terminated string, but this is not explicitly documented.
Can I safely assume that MLGetUTF8String will always return a null-terminated string, or was it just an accident that in my test it appeared to return one? If would spare having to copy the whole string just to insert a '\0' at the end.
I actually received an answer to this
from another user but I was hoping for some more 'official' reassurance, considering that this is undocumented. Or perhaps suggest that it be documented, if possible.
Steve Wilson, Wolfram Research
11 years ago
MLGetUTF8String() is not guaranteed to return a null-terminated string and one should not rely on that behavior. One should always copy the contents of a string returned
by MathLink into the applications own memory so that the library can free that resource as soon as possible.
Reply to this discussion
in reply to
Community posts can be styled and formatted using the
Tag limit exceeded
Note: Only the first five people you tag will receive an email notification; the other tagged names will appear as links to their profiles.
Add a file to this post
Follow this discussion
Be respectful. Review our
to understand your role and responsibilities.
Wolfram|Alpha Notebook Edition
Volume & Site Licensing
Enterprise Private Cloud
Service Plans Benefits
Wolfram Language Documentation
Wolfram Language Introductory Book
Get Started with Wolfram
Fast Introduction for Programmers
Fast Introduction for Math Students
Webinars & Training
Connected Devices Project
Wolfram Data Drop
Wolfram + Raspberry Pi
. All rights reserved.
Learn how »