www.digitalmars.com         C & C++   DMDScript  

D.gnu - is there any way to stop GDC complain about non-utf source encoding?

reply "ketmar" <ketmar ketmar.no-ip.org> writes:
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.
Apr 26 2014
next sibling parent "Kagamin" <spam here.lot> writes:
AFAIK, gcc has an option to specify source encoding, maybe gdc 
supports it too?
Apr 29 2014
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
Ah, wait, D doesn't support source in non-unicode encoding. Try 
to place the text in a separate file and import it.
Apr 29 2014
prev sibling next sibling parent "Dejan Lekic" <dejan.lekic gmail.com> writes:
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
prev sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
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
May 01 2014