QTextEdit t; t.setHtml(" "); displays a small ‘a’ with acute accent instead of a non-breaking space. This happens only on Windows not Linux or FreeBSD.
What might be causing this? A bug in Windows/Qt? How can I fix this?
(Qt 4.5 on Windows Vista x64 pro. My locale is the default ‘C’.)
Update: I have a feeling that this is bug in Qt/Windows (have already submitted a bug report). I have created a workaround but it’s ugly and involves changing my formatting alogrithm and uses <pre> </pre> with CSS to produce the desired output.
Is there any simpler workaround?
Update: &8194; and &8195; both work as suggested by ‘wcm’. Is it safe to assume that this will work for other users too?
not working is probably still a bug, but &8194; appears to be an acceptable workaround(?).
Update: Turns out I missed something important: in Qt/Windows renders incorrectly only with the particular monotype font that I was using called ‘Terminal’. When I switched to ‘Lucida Console’ (or any other font for that matter) renders correctly! Man I wish I had noticed this earlier! Damn. So obviously there is a bug somewhere (most likely in Qt). But nevermind that, atleast for me using a different font has solved the problem.
Update: It’s not a bug in Qt as I previously thought.
To know the reason why is being rendered incorrectly please see Tewha’s answer.
[SOLVED]
I see you’ve mostly figured this out, but I thought I’d add the “why” of it. The Terminal font is based on code page 437, aka DOS-US. á is in position 160.
There aren’t many fonts for code page 437. I think Terminal is the only TrueType one, in fact! At any rate, if you’re not explicitly trying to display old school DOS graphics, you shouldn’t be using Terminal.
What’s code page 437 all about? It’s “high ASCII”, circa 1981. In addition to the usual 32-127 characters, it includes a few accented letters, box graphic characters to draw borders around things, some mathematical symbols and even symbols for the four suits of cards! But the world moved a different way, so aside from 32-127, even the glyphs that are usually available in other fonts aren’t where you’d expect them to be. If you were running an old text-mode MSDOS program in a window, it would be using a code page 437 font.
See “code page 437” (Wikipedia) for more information.