init_unistr2 length calculation

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

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            -------------------------
 SAMBA Team                 ----------------------
 GnuPG Key                  ----
 "You can never go home again, Oatman, but I guess you can shop there."  
                            --John Cusack - "Grosse Point Blank" (1997)

Version: GnuPG v1.2.0 (GNU/Linux)
Comment: For info see


More information about the samba-technical mailing list