Summary: Allow implicit conversion of string literal (in
                    particular x"") to immutable(ubyte)[]
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P4
         Component: DMD

--- Comment #0 from 2011-04-29 09:10:59 PDT ---
As titled.

Some string features like \x escape characters and x"" string may produce an
invalid UTF string. This may not be useful for the 'string' type, but is very
useful for creating a 'ubyte[]' type which isn't limited by the character set.

Unfortunately, correctly a string literal can only be implicitly converted to
an immutable char/wchar/dchar pointer/array, so the following will not work
without a cast:

void main() {
    immutable(ubyte)[] a = x"1a b2 3c d4 5e f6";
$ dmd x
x.d(2): Error: cannot implicitly convert expression ("\x1a\xb2<\xd4^\xf6") of
type string to immutable(ubyte)[]

(See also issue 2193 for a generalization.)

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to