[GHC] #4471: Incorrect Unicode output on Windows Console
GHC
cvs-ghc at haskell.org
Thu Nov 25 05:16:04 EST 2010
#4471: Incorrect Unicode output on Windows Console
-------------------------+--------------------------------------------------
Reporter: sankeld | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.2.1
Component: Compiler | Version: 6.12.3
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Windows | Blocking:
Architecture: x86 | Failure: Incorrect result at runtime
-------------------------+--------------------------------------------------
Comment(by simonmar):
That does clarify things a lot, thanks for that. To summarise:
* the bug is that Win32 `WriteFile()` returns the wrong result when
writing to a Console in codepage 65001. Furthermore, the result it
actually returns is the number of characters written to the console, which
depends on the actual ''font'' being used! (if the font doesn't have the
required Unicode glyph, it falls back to outputting characters
corresponding to the raw UTF-8 bytes).
The only way to work around the bug seems to be to use `WriteConsole()`
and write Unicode characters directly. If a Handle is attached to a
console, then all writes must be decoded from the codepage encoding to
UTF-16 before being written using `WriteConsole()`. Even better would be
to bypass the codepage encoding entirely and encode directly from UTF-32
to UTF-16 in the IO library. None of this is particularly easy, though.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4471#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list