[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Endianness-specific
From: |
Ludovic Courtès |
Subject: |
Endianness-specific |
Date: |
Sat, 06 Oct 2007 19:43:24 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Hi,
I'm trying to implement functions that convert a string in the current
locale encoding to its UTF-{16,32} representation, for a given
endianness.
`u16-conv-from-enc.c' reads this:
/* Name of UTF-16 encoding with machine dependent endianness and alignment.
*/
#if defined _LIBICONV_VERSION || (__GLIBC__ > 2) || (__GLIBC__ == 2 &&
__GLIBC_MINOR__ >= 2)
# ifdef WORDS_BIGENDIAN
# define UTF16_NAME "UTF-16BE"
# else
# define UTF16_NAME "UTF-16LE"
# endif
#endif
... which means we can't portably determine the name of a UTF-{16,32}
for a specific endianness, right?
Then, for portability, I'd end up re-implementing the "#else" part of
`u-conv-from-enc.h'.
Conclusion: `u16_conv_from_encoding ()' and friends really lack an
ENDIANNESS parameter. Any idea how we could extend the API in
"uniconv.h" to support it? Perhaps we could add `u{16,32}{be,le}_'
variants of these functions? Or add, e.g.,
extern int
u16_endianness_conv_to_encoding (const char *tocode,
enum charset_endianness endianness,
enum iconv_ilseq_handler handler,
const uint16_t *src, size_t srclen,
size_t *offsets,
char **resultp, size_t *lengthp);
Opinions?
Thanks,
Ludovic.
- Endianness-specific,
Ludovic Courtès <=