Oskar Liljeblad wrote: > it would however be very useful if these functions would > null-terminate the generated strings properly as well. I assume str_iconv > and str_cd_iconv would add a single null-byte
Yes. the str_* functions expect a C string as input and produce one as output, i.e. the from_code and the to_code cannot be UTF-7/16/32. > but in some cases you'll need > two or even four null-bytes - e.g. when converting to UTF-16/UCS-2 and > UTF-32/UCS-4. The majority of the cases deal with C strings. UTF-16/32 occur more rarely than you might think. For this case, and for the case of C strings with possibly embedded NUL bytes, the function mem_cd_iconv is entirely sufficient. > One way would be to simply add four null bytes instead of one > all the time, or create another set of functions accepting a > 'size_t n_null_bytes' argument. This would work for UTF-16/32, but not for UTF-7. Bruno