Relaxing the definition of isSomeString and isNarrowString

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 24 14:23:57 PDT 2014


24-Aug-2014 22:36, ketmar via Digitalmars-d пишет:
> On Sun, 24 Aug 2014 18:28:51 +0000
> via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>
> and D parser unconditionally assumes that source code is in UTF-8 too.
> which makes great PITA for me: i can't use strings (any string-like
> literals, actually) in Latin-1 (for example) without ugly
> "\x..\x..\x..". hate it.
>

Just make a function that translates UTF-8 into Latin-1, use ubyte for 
Latin-1.

Then this neat trick will keep literal compile-time constant:

enum latin(alias str) = toLatin1(str);

(where toLatin some normal function that does the translation)

Then use it as latin!"some-string-in-latin1"

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list