digitalmars.D.bugs - [Issue 5909] New: Allow implicit conversion of string literal (in particular x"") to immutable(ubyte)[]
- d-bugmail puremagic.com (34/34) Apr 29 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5909
http://d.puremagic.com/issues/show_bug.cgi?id=5909 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 AssignedTo: nobody puremagic.com ReportedBy: kennytm gmail.com --- Comment #0 from kennytm gmail.com 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 29 2011