C strings - byte, ubyte or char? (Discussion from Bugzilla)

Regan Heath regan at netmail.co.nz
Thu Oct 4 07:40:32 PDT 2007


Stewart Gordon wrote:
> First it was proposed that the C string type should become ubyte*, 
> rather than char*, in D.  (Actually, whether it should be byte or ubyte 
> depends on whether the underlying C implementation treats unqualified 
> char as signed or unsigned.  But it probably doesn't matter to the 
> implementations of most string functions.)

+votes

> This would entail:
...
> - changing the language to allow string literals to serve as ubyte* as 
> well as the types that they already serve as.

In this case doesn't the compiler need to know which encoding to use?

For example say you're passing a string literal to MessageBoxA it needs 
to encode the string literal using the local code page, right?

Shouldn't it also be possible to pass a string literal to MessageBoxW, 
in which case the same treatment needs to be applied to wchar_t* AKA short*.

Regan



More information about the Digitalmars-d mailing list