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.



Reply via email to