Bug 3784 – Interpretation of hex string and escape sequences unclear
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-02-08T19:20:00Z
Last change time
2015-06-09T01:27:41Z
Keywords
spec
Assigned to
nobody
Creator
jlquinn
Comments
Comment #0 by jlquinn — 2010-02-08T19:20:07Z
Are the contents of a hex string interpreted as bytes or as the postfix indicates?
string a = x"fedcfedc"; // compiles
dstring b = x"fedcfedc"d; // error - illegal unicode.
The compiler apparently considers the double-quoted contents to be UTF-8 that must be converted to UTF-32 due to the 'd' postfix. The spec does not make this clear. It is reasonable to read the spec as allowing the second declaration.
A similar question exists about escape sequences since these are deemed equivalent to:
string c = "\xfe\xdc\xfe\xdc";
dstring d = "\xfe\xdc\xfe\xdc"d;
Also, is 'd' equivalent to:
dstring e = "\ufedc\ufedc"d;
or
dstring f = "\Ufedcfedc"d;
both of which are illegal unicode?
Comment #1 by jlquinn — 2010-02-08T19:22:40Z
Apparently I reported this before, sorry:
Bug 2639
*** This issue has been marked as a duplicate of issue 2639 ***