digitalmars.D.learn - HexString and "Invalid trailing code unit" error
- Parke (26/26) Nov 27 2013 TDPL, page 37, says:
TDPL, page 37, says: "Hex strings are useful for defining raw data; the compiler makes no attempt whatsoever to interpret the contents as Unicode characters or anything else but hexadecimal digits." But: static immutable (char[32]) s0 = x"0000"; // compiles static string s1 = x"cccc"; // compiles static immutable (char[]) s2 = x"cccc"; // compiles static immutable (char[32]) s3 = x"cccc"; // Error: Invalid trailing code unit static immutable (char[32]) s4 = x"cc"; // Error: Truncated UTF-8 sequence static immutable (ubyte[]) s5 = x"cccc"; // Error: cannot implicitly convert ... static immutable (ubyte[32]) s6 = x"cccc"; // Error: Invalid trailing code unit // Error: cannot implicitly convert ... "Invalid trailing code unit" and "Truncated UTF-8 sequence" certainly look like Unicode interpretation errors to me. (Of course, what I would really like to do is initialize a ubyte array with a hex string, preferably without a cast.) I cannot find any relevant documentation on either of these pages. http://dlang.org/lex.html http://dlang.org/arrays.html#strings Any advice would be appreciated. Thanks!
Nov 27 2013