Thread overview
is there any way to stop GDC complain about non-utf source encoding?
Apr 26, 2014
ketmar
Apr 29, 2014
Kagamin
Apr 29, 2014
Kagamin
May 01, 2014
Dejan Lekic
May 01, 2014
bearophile
April 26, 2014
the thing is: i have a file where i want to use some one-byte encodings which looks like "bad utf-8". compiler complains even if i'm using that in comments (and i want such encodings in one-byte strings too!). can i somehow force it to shut up and just accept what i wrote?

yes, i know that "just convert that to utf-8 and it will be fine" solution exists. unfortunately, i don't want utf-8 overhead for my small gfx library. it using byte strings, and it using codes [128…255] to draw some specific chars. i don't want to add unicode mapping table to library, i just want the compiler to accept non-utf one-byte strings silently when i told it to.

yeah, i know that i can write such strings like this: "\xc2\xcc\xd1!". this is not the way i want to write clear text, and there is no way to mixin code without mixin(), so i can't write compile-time macro for it too.

tnx.
April 29, 2014
AFAIK, gcc has an option to specify source encoding, maybe gdc supports it too?
April 29, 2014
Ah, wait, D doesn't support source in non-unicode encoding. Try to place the text in a separate file and import it.
May 01, 2014
You do not have a choice mate, D source files must be UTF-8.

Check this page: http://dlang.org/lex

Let me extract the relevant part of it:

Source Text
D source text can be in one of the following formats:

    ASCII
    UTF-8
    UTF-16BE
    UTF-16LE
    UTF-32BE
    UTF-32LE

May 01, 2014
ketmar:

> i just want the compiler to accept non-utf one-byte strings
> silently when i told it to.

In D there are also "Hex strings" for that purpose.

Bye,
bearophile