[Issue 1985] New: import expression should return ubyte[] not string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 10 18:57:20 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1985

           Summary: import expression should return ubyte[] not string
           Product: D
           Version: 1.028
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: wbaxter at gmail.com


The compiler does not convert the encoding of the imported files to utf8, so it
should not pretend that it knows the contents of the file are utf8.

In fact, probably one of the most practically useful applications of the import
expression is to import binary files, which it is impossible for the compiler
to put in utf8 format.

So the conclusion is that import("foo.dat") should evaluate to ubyte[], not
char[].  It can be cast to char[] if the developer happens to know that the
file is, in fact, text.  Currently the situation is reversed -- the data must
be cast to ubyte[] if the developer knows it is not, in fact, utf8 text.


-- 



More information about the Digitalmars-d-bugs mailing list