Behdad Esfahbod wrote on 2004-04-07 09:02 UTC:
> On Wed, 7 Apr 2004, Michael B Allen wrote:
> > AFAICT iconv(3) requires that the length of the input be known in advance.
> > This is very unfortunate for zero terminated strings as it requires the
> > user inspect the string in an encoding specific way to determine it's
> > length. Is there simply no way around this?
> 
> AFAICS it expects the length of the input in bytes, so you simply
> pass strlen() for zero-terminated strings.

But strlen() works only for zero-terminated strings in multi-byte
encodings. It will fail on wide character encodings such as UTF-16 and
UTF-32. And wcslen() is probably also of no help if you have a byte
array, not a wchar_t array.

On the other hand, I have great difficulty to envision a real-world
situation, where the user of iconv

  - knows that the input is zero terminated
  - does not know whether this is an 8-bit, 16-bit or 32-bit
    wide and aligned zero

which is the situation it seems to me Michael might refer to.

So the question to Michael is: What is the actual problem you want to
solve?

Markus

-- 
Markus Kuhn, Computer Lab, Univ of Cambridge, GB
http://www.cl.cam.ac.uk/~mgk25/ | __oo_O..O_oo__


--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to