Re: Behaviour of g_utf8_to_utf16
- From: David Nečas <yeti physics muni cz>
- To: Weeble <clockworksaint gmail com>
- Cc: gtk-list gnome org
- Subject: Re: Behaviour of g_utf8_to_utf16
- Date: Wed, 20 Jun 2012 13:23:08 +0200
On Tue, Jun 19, 2012 at 10:28:56PM +0100, Weeble wrote:
> As far as I can tell by experimentation, g_utf8_to_utf16 always stops
> at the first nul in a string, even when a positive value is passed for
> the len argument. If I have a UTF8 string with embedded nuls (of known
> length, of course), is there a good way to convert it to UTF16 with
> GLib?
I would just write a wrapper around g_utf8_to_utf16() that would use it
in a cycle until the full length is reached and handle the nul characters.
> I thought at first that passing a positive len would have this
> effect because I read "If len < 0, then the string is nul-terminated"
The string is terminated by a nul character or explicit length,
whichever comes *first* – this is the standard behaviour of all libc and
glib string functions. Passing len < 0 simply means that the second
condition never realises.
Yeti
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]