3784 – Interpretation of hex string and escape sequences unclear

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3784 - Interpretation of hex string and escape sequences unclear
Summary: Interpretation of hex string and escape sequences unclear
Status: RESOLVED DUPLICATE of issue 2639
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL: http://digitalmars.com/d/2.0/lex.html
Keywords: spec
Depends on:
Blocks:
Reported: 2010年02月08日 19:20 UTC by Jerry Quinn
Modified: 2015年06月09日 01:27 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Jerry Quinn 2010年02月08日 19:20:07 UTC
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 Jerry Quinn 2010年02月08日 19:22:40 UTC
Apparently I reported this before, sorry:
Bug 2639
*** This issue has been marked as a duplicate of issue 2639 ***


AltStyle によって変換されたページ (->オリジナル) /