IDL [string] attribute (was svn commit: samba r11105 ...)

Michael B Allen mba2000 at
Mon Oct 17 23:57:44 GMT 2005

On Mon, 17 Oct 2005 22:36:36 +0200
Jelmer Vernooij <jelmer at> wrote:

> > Also, about the type 'uint16' - for midlc I was going to represent
> > [string] wchar_t *str with the locale dependant codeset internally
> > (e.g. UTF-8) and UTF-16LE as the wire encoding. This allows
> > existing IDL written for Windows to be used elsewhere (e.g. UNIX)
> > as-is. Note that this means that in the generated headers and
> > stubs, the 'wchar_t' type must be converted to a generic character
> > type to be defined by the user (e.g. if locale charset is UTF-8
> > then typedef unsigned char char_t) because 'wchar_t' is a standard
> > C library type.
> I'm not a big fan of assuming codesets depending on the data type. For

Just to infer the default encoding? That's no big deal. If it's wchar_t
and there's no codeset attrbute, you make the codeset UTF-16LE. And if
it's char without a codeset attr then make it DOS. You should have a
default so you might as well exercise the Principle of Least Surprise.

> example, having a seperate codeset() attribute allows us to do
> conversion on text data that doesn't have a [string] attribute (such
> as the string structure used by the lsa and netlogon interfaces). It
> also forces the user to think about the format data will have on the
> wire.
> Doing "automatic" conversion is still possible if the user wants it,
> simplify by defining something like this on top of your IDL file:
> #define wchar_t [charset(UTF-16)] wchar_t
> #define char [charset(DOS)] char
> I can be convinced otherwise though, if you can come up with a good
> reason :-)

But you still have to edit IDL imported from a Windows project. Even if
it is just two lines, it's just not necessary. Infer the default encoding
from the IDL type.

I can't see these defines really working anyway. What about 'const
wchar_t *' or 'struct { unsigned char flags; ...'? Even if they were
typedefs I think you'll have problems.

But I agree that having a separate 'codeset' attribute is nice in case
you want to do something this.


More information about the samba-technical mailing list