Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13553 > unrolled thread
| Started by | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| First post | 2013-02-19 06:09 +0000 |
| Last post | 2013-02-19 06:09 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Does MLGetUTF8String() return a null-terminated string? Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2013-02-19 06:09 +0000
| From | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| Date | 2013-02-19 06:09 +0000 |
| Subject | Re: Does MLGetUTF8String() return a null-terminated string? |
| Message-ID | <kfv4ua$3fl$1@smc.vnet.net> |
Hi, yes, I'm pretty sure it does. When you look at the LibraryLink examples, you see that LibraryLink uses UTF8 strings as well. In the example code you find char *instring = MArgument_getUTF8String(Args[0]); char *substring = MArgument_getUTF8String(Args[1]); mint i, n = strlen(instring); mint slen = strlen(substring); which doesn't uses the length but calls strlen instead. If the string is not null-terminated, strlen would fail, because how should it know whether the string is over if not by the final \0. When MathLink and LibraryLink share the same Wolfram type (what they hopefully do), you should be on the safe side. Cheers Patrick On Feb 18, 2013, at 12:02 PM, Szabolcs Horv=E1t <szhorvat@gmail.com> wrote: > > Does the C MathLink function MLGetUTF8String() return a null-terminated > string? The documentation does not say that it does and it returns the > length of the string as well. But if it did, it would spare me some > copying, as my target requires a null-terminated UTF-8 string. > >
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web