[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iconv modules

From: Oskar Liljeblad
Subject: Re: iconv modules
Date: Mon, 4 Sep 2006 15:01:08 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

On Monday, September 04, 2006 at 14:53, Bruno Haible wrote:

Hi Bruno

> All of these options are useful in some way or the other. Therefore I'd like
> to keep all the options, and distinguish them through a consistent
> nomenclature.
>   - "str" vs. "mem",
>   - infix "cd" vs. none (similar to 'stat' and 'fstat' - the most natural 
> among
>     the two has no prefix, the one taking a descriptor has a prefix),
>   - "x" for checked memory allocation.
> So the proposal is:
>   - Module 'striconv' (LGPL):
>     exzern char *str_iconv (const char *string,
>                             const char *from_code, const char *to_code);
>     extern char *str_cd_iconv (const char *string, iconv_t cd);
>     extern int mem_cd_iconv (const char *start, size_t length, iconv_t cd,
>                              char **resultp, size_t *lengthp);

Sounds good to me - 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, 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. 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.


Oskar Liljeblad (address@hidden)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]