how to string → uint* ?
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 28 04:32:30 PDT 2015
On Sunday, 28 June 2015 at 10:29:48 UTC, Mike Parker wrote:
> 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?
Invalid UTF8 in strings currently throws on decoding, but it's
being changed to asserts, because it's against specification and
therefore (the consequence of) a bug somewhere in the program.
One reason for this is to make decoding @nogc, the other is
simply correctness: a variable having the type `char[]` should be
a guarantee that it contains valid UTF8.
I don't know of any actual problems though, but if they happen,
they will soon be Errors instead of Exceptions.
More information about the Digitalmars-d-learn
mailing list