init_unistr2 length calculation

Gerald (Jerry) Carter jerry at samba.org
Fri Feb 14 18:32:44 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 13 Feb 2003, Shirish Kalele wrote:

> >> In init_unistr2, the string length for the UNISTR2 structure seems to
> >> be set equal to the number of bytes occupied by the string when
> >> encoded in the Unix charset (i.e. the value returned by strlen()).
> >> This is not necessarily the number of characters in the string (given
> >> UTF-8 and other variable-byte charsets).
> >>
> >> Shouldn't this actually be set to half the number of bytes occupied
> >> by the string after encoding it in UCS2? Here's a patch that does
> >> this.
> >
> >I think you might get into trouble here due to difference in the MS
> >unicode marshalling "flexibility".
> 
> I don't understand. Could you elaborate?

i guess if (length_of_bytes_in_orig_string != num_character_in_string) 
then we would have a problem.  Had to think though this a bit.

I think I misunderstood you to start with.  I thought we were talking 
about UNISTR2 length == num_characters.  My point was that sometimes this 
is actually == num_characters*2 (as you mentioned).

Ignore me.  My memory deteriates as I get older.....



cheers, jerry
 ----------------------------------------------------------------------
 Hewlett-Packard            ------------------------- http://www.hp.com
 SAMBA Team                 ---------------------- http://www.samba.org
 GnuPG Key                  ---- http://www.plainjoe.org/gpg_public.asc
 "You can never go home again, Oatman, but I guess you can shop there."  
                            --John Cusack - "Grosse Point Blank" (1997)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)
Comment: For info see http://quantumlab.net/pine_privacy_guard/

iD8DBQE+TTZMIR7qMdg1EfYRAgOwAKC4fw6AgaMBIQNKO8HgfPDhYG31nACfToeG
DhQ+TtLtswfK/U2Th0X5XK4=
=8I/J
-----END PGP SIGNATURE-----



More information about the samba-technical mailing list