Utf8 to Utf32 cast cost
Daniel Kozák via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 8 03:51:31 PDT 2015
On Mon, 08 Jun 2015 10:41:59 +0000
Kadir Erdem Demir via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:
> I want to use my char array with awesome, cool std.algorithm
> functions. Since many of this algorithms requires like slicing
> etc.. I prefer to create my string with Utf32 chars. But by
> default all strings literals are Utf8 for performance.
>
> With my current knowledge I use to!dhar to convert Utf8[](or
> char[]) to Utf32[](or dchar[])
>
> dchar[] range = to!dchar("erdem".dup)
>
> How costly is this?
> Is there a way which I can have Utf32 string directly without a
> cast?
dstring str = "erdem"d;
dstring str2 = std.utf.toUTF32(someUtf8Or16Or32String);
More information about the Digitalmars-d-learn
mailing list