how to string → uint* ?

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 28 03:29:47 PDT 2015


On 6/28/2015 7:08 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" 
wrote:
> In addition to what anonymous said, you might want to raise a bug report
> with Derelict, because the function signatures are arguable wrong,
> though that depends on whether Derelict wants to provide a strict
> one-to-one mapping of the C code, or one that is already somewhat
> adapted to D:
>
> https://github.com/DerelictOrg/DerelictSFML2/blob/master/source/derelict/sfml2/graphics.d#L521-L522
>
>
> alias da_sfText_setString = void function( sfText*,const( char )* );
>
> The documentation says that this is for ANSI strings, but `char` in D is
> defined to be a *UTF8* code unit. Instead, the type should be
> `const(ubyte)*`.

I've been mapping D char to C char in Derelict packages for 11 years. 
It's also what's recommended on the page about interfacing to C[1]. 
Although I do understand your point, I'm curious if anyone is actually 
taking the ubyte approach these days? Or has anyone actually encountered 
a problem with the char->char mapping?

>
> alias da_sfText_setUnicodeString = void function( sfText*,const(
> sfUint32 )* );
>
> Probably better to use `const(dchar)*` here.

Agreed. That's what I've been doing in recent additions.

[1] http://dlang.org/interfaceToC.html



More information about the Digitalmars-d-learn mailing list