9

In some of its API function Microsoft use the "multi-string" format to specify a list of strings.

As I understand it, a multi-string is a null-terminated buffer of concatenated null-terminated strings. But this can also be interpreted as a list of strings, separated by a null character and terminated by two null characters.

Here comes an example. A list composed of the following items:

"apple", "banana", "orange"

Becomes:

apple\0banana\0orange\0\0

But now I wonder:

How would an empty list be represented ?

Would it be:

\0

Or:

\0\0

I failed to found an accurate documentation that clarifies this. Any clue ?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
ereOn
  • 53,676
  • 39
  • 161
  • 238

3 Answers3

9

\0

dan04
  • 87,747
  • 23
  • 163
  • 198
  • 2
    I bet this is your shortest answer ever ;) It perfectly answers my question though. Thank you. – ereOn Aug 26 '10 at 15:18
  • 2
    I'm a man of few words. If only you could say "It perfectly answers my question though. Thank you." just by clicking a checkmark... – dan04 Aug 26 '10 at 15:26
  • So its not possible to have an empty string ("") in such a list? – torak Aug 26 '10 at 15:29
  • 1
    No, it's not, just like you can't have `\0` inside a C string. – dan04 Aug 26 '10 at 15:30
4

It would be \0.

Raymond Chen describes how this works on his blog: the list of strings is terminated by an empty string. If the first string in the list is empty, the list itself is empty.

James McNellis
  • 348,265
  • 75
  • 913
  • 977
2

If you are working with these, many years ago, I wrote an STL style iterator which works on them:

http://noveltheory.com/iterators/Iterator_N3.htm

James Curran
  • 101,701
  • 37
  • 181
  • 258