user112354: I'm writing a script in C that is mean to make the usage of my c-lightning wallet more convenient. And so I have to
specify a limit of characters (l is a variable that stands for label):
puts("The label(a unique string or number)?");
        char l[15];
        fgets(l, 15, stdin);
        l[strcspn(l, "\n")] = 0;

I arbitrarily decided on 15 not knowing whether lightning-cli invoice would accept such long string. Although help invoice gives some info about the label:

The  label  must be a unique string or number (which is treated as a string, so "01" is different
from "1"); it is never revealed to other nodes on the lightning network, but it can  be  used  to
query the status of this invoice.

it does not specify it's length nor its character set? Are UTF-8 characters accepted within the label or should I use only ASCII character set? What is the maximum size / number of characters of the label?

user81940: If you look at the source code you can find the data base schema of the SQLite3 database that is being used to store invoices at: https://github.com/ElementsProject/lightning/blob/426ff0abfff8b080b22095b9f0b670c7192f54ea/wallet/db.c#L185
This indicates that the label field is of type TEXT. According to the SQLite3 Documentation this means:

TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).

Of course you need to check the if lightningd can also handle such long strings. the labels are stored in invoice_details which which is defined at:
https://github.com/ElementsProject/lightning/blob/335ef3fb69f923f6f30213f68881d10ee6d977ed/wallet/wallet.h#L777
from there you can see that it is of type * json_escape which comes from rusty's ccan libraries and is defined at:
https://github.com/ElementsProject/lightning/blob/ade10e7fc4dacbb9d635b05152c7dc38c0896ce7/ccan/ccan/json_escape/json_escape.h
There it says:
/* Type differentiation for a correctly-escaped JSON string */
struct json_escape {
    /* NUL terminated string. */
    char s[1];
};

/**
 * json_escape - escape a valid UTF-8 string.
 * @ctx: tal context to allocate from.
 * @str: the string to escape.
 *
 * Allocates and returns a valid JSON string (without surrounding quotes).
 */
struct json_escape *json_escape(const tal_t *ctx, const char *str TAKES);

To my understanding this indicates indeed that as long as you have memory and disc you should be able to store UTF-8 strings of arbitrary length.

112354: <p>I'm writing a script <a href="https://en.wikipedia.org/wiki/C_(programming_language)" rel="nofollow noreferrer">in C</a> that is mean to make the usage of my c-lightning wallet more convenient. And so I have to
specify a limit of characters (<code>l</code> is a variable that stands for label):</p>
<pre><code>puts(&quot;The label(a unique string or number)?&quot;);
        char l[15];
        fgets(l, 15, stdin);
        l[strcspn(l, &quot;\n&quot;)] = 0;
</code></pre>
<p>I arbitrarily decided on 15 not knowing whether <code>lightning-cli invoice</code> would accept such long string. Although <code>help invoice</code> gives some info about the label:</p>
<blockquote>
<p>The  label  must be a unique string or number (which is treated as a string, so &quot;01&quot; is different
from &quot;1&quot;); it is never revealed to other nodes on the lightning network, but it can  be  used  to
query the status of this invoice.</p>
</blockquote>
<p>it does not specify it's length nor its character set? Are <a href="https://en.wikipedia.org/wiki/UTF-8" rel="nofollow noreferrer">UTF-8 characters</a> accepted within the label or should I use only <a href="https://en.wikipedia.org/wiki/ASCII" rel="nofollow noreferrer">ASCII</a> character set? What is the maximum size / number of characters of the label?</p>
 81940: <p>If you look at the source code you can find the data base schema of the SQLite3 database that is being used to store invoices at: <a href="https://github.com/ElementsProject/lightning/blob/426ff0abfff8b080b22095b9f0b670c7192f54ea/wallet/db.c#L185" rel="nofollow noreferrer">https://github.com/ElementsProject/lightning/blob/426ff0abfff8b080b22095b9f0b670c7192f54ea/wallet/db.c#L185</a></p>
<p>This indicates that the label field is of type TEXT. <a href="https://www.sqlite.org/datatype3.html" rel="nofollow noreferrer">According to the SQLite3 Documentation</a> this means:</p>
<blockquote>
<p>TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).</p>
</blockquote>
<p>Of course you need to check the if lightningd can also handle such long strings. the labels are stored in <code>invoice_details</code> which which is defined at:</p>
<p><a href="https://github.com/ElementsProject/lightning/blob/335ef3fb69f923f6f30213f68881d10ee6d977ed/wallet/wallet.h#L777" rel="nofollow noreferrer">https://github.com/ElementsProject/lightning/blob/335ef3fb69f923f6f30213f68881d10ee6d977ed/wallet/wallet.h#L777</a></p>
<p>from there you can see that it is of type <code>* json_escape</code> which comes from rusty's ccan libraries and is defined at:</p>
<p><a href="https://github.com/ElementsProject/lightning/blob/ade10e7fc4dacbb9d635b05152c7dc38c0896ce7/ccan/ccan/json_escape/json_escape.h" rel="nofollow noreferrer">https://github.com/ElementsProject/lightning/blob/ade10e7fc4dacbb9d635b05152c7dc38c0896ce7/ccan/ccan/json_escape/json_escape.h</a></p>
<p>There it says:</p>
<pre><code>/* Type differentiation for a correctly-escaped JSON string */
struct json_escape {
    /* NUL terminated string. */
    char s[1];
};

/**
 * json_escape - escape a valid UTF-8 string.
 * @ctx: tal context to allocate from.
 * @str: the string to escape.
 *
 * Allocates and returns a valid JSON string (without surrounding quotes).
 */
struct json_escape *json_escape(const tal_t *ctx, const char *str TAKES);
</code></pre>
<p>To my understanding this indicates indeed that as long as you have memory and disc you should be able to store UTF-8 strings of arbitrary length.</p>
