On Montag, 11. Februar 2008, Udo Richter wrote:
> Well, that leads to the question whether s is unchanged in case of a -1
> error return, and whether this would work:
I can confirm that. The man page however says the value will be undefined.
My current understanding is:
1. dont forget to call setlocale! Normally setlocale(LC_ALL,"")
2. if locale is UTF-8, asprintf returns -1 if the string contains illegal
UTF-8 characters anywhere
3. this and out of memory are the only reasons I know for result -1. The
man page to asprintf says there could be other errors than out of memory
but mentions none.
4. If result -1, the buffer pointer stays unchanged, see man page
5. if locale is UTF-8 and a maximum length is defined as in %.9s, and if
%.9s would cut a multibyte char, only 8 chars will be used. See example
from Ludwig Nussel.
What I don't know where in the man pages this is explained - I did not
find anything about it. Neither man asprintf or man printf
vdr mailing list