Bug 1024 – invalid UTF-8 sequence for \u00B6 (¶) in comment
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-03-04T14:47:00Z
Last change time
2014-02-16T15:22:22Z
Assigned to
bugzilla
Creator
benoit
Comments
Comment #0 by benoit — 2007-03-04T14:47:20Z
Having \u00b6 in a single line comment (//) gives the message.
An editor correctly shows "¶".
Comment #1 by fvbommel — 2007-03-04T15:41:45Z
Was the encoding UTF-8? Did your file start with the appropriate BOM? (DMD requires a BOM to consider a file anything other than pure ASCII)
Here's a test for you, try to reproduce this:
---
urxae@urxae:~/tmp$ cat utf.d
//¶
urxae@urxae:~/tmp$ hd utf.d
00000000 ef bb bf 2f 2f c2 b6 0a |...//...|
00000008
urxae@urxae:~/tmp$ dmd -c utf.d
urxae@urxae:~/tmp$
---
The first command shows the contents of the file (apparently cat doesn't handle BOMs, it just sends it straight to the console; that's where the extra symbol comes from).
The second shows the hexdump of the file. Note the 'ef bb bf' UTF-8 BOM, and the 'c2 b6' encoding of the '¶'.
The third command shows DMD compiling the file successfully.
See http://www.digitalmars.com/d/lex.html (under "Source Text") for the details on encodings accepted by DMD
Comment #2 by fvbommel — 2007-03-04T15:45:08Z
(In reply to comment #1)
[snip]
> //¶
[snip]
> (apparently cat doesn't handle
> BOMs, it just sends it straight to the console; that's where the extra symbol
> comes from).
And apparently somewhere along the line from bugzilla to the newsgroup message showing up in my Thunderbird, that character is stripped...
(for anyone only reading this in the newsgroups trying to figure out what I was talking about: look at the bugzilla page)
Comment #3 by benoit — 2007-03-04T16:15:29Z
in my thunderbird it shows up correctly.
But I changed the standard encoding to utf8.
You are rigth with the bom. I added a bom to my file, and it compiles.
Comment #4 by benoit — 2007-03-04T16:41:19Z
hm, i did forget to reactivate the code that produces the utf chars....
Now i can say, it also works without BOM, and my problem was a coding error in writing the file.
char[] line;
...
line ~= '\u00b6'; // This made the corrupt file content
line ~= "\u00b6"; // So the file is written correctly
// write the line into the file