Casting between char[]/wchar[]/dchar[]

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Aug 5 14:23:08 PDT 2006


"Hasan Aljudy" <hasan.aljudy at gmail.com> wrote in message 
news:eb2u9n$psv$1 at digitaldaemon.com...

> Can I ask you atleast to simplify the conversion by adding properties utf* 
> to char/wchar/dchar arrays?
>
> so, if I have:
> ----
> char[] process( char[] str ) { ... }
>
> ...
>
> dchar[] my32str = .....;
>
> //I can write
> my32str = process( my32str.utf8 ).utf32;
>
> //instead of
> //my32str = toUTF32( process( toUTF8( my32str ) ) );

import utf = std.utf;

wchar[] utf16(char[] s)
{
    return utf.toUTF16(s);
}

...

char[] s = "hello";
wchar[] t = s.utf16;

 ;)

Aren't first-array-param-as-a-property functions cool? 





More information about the Digitalmars-d mailing list