Cygwin fails to utilize Unicode replacement character

Steven Penny
Mon Sep 3 22:15:00 GMT 2018

On Mon, 3 Sep 2018 23:02:58, Corinna Vinschen wrote:
> I can't. I only have a limited set of fonts available in the console.

> What I just did was calling the GetFontUnicodeRanges function
> for each font, and it turns out that none of the fonts support
> 0xfffd "REPLACEMENT CHARACTER", but all three support 0xfffc
> "OBJECT REPLACEMENT CHARACTER".  I expanded the testcase to check
> for this with GetGlyphIndicesW and, lo and behold, the result
> makes sense.

Here is my code if it helps:

    #include <stdio.h>
    #include <windows.h>
    int main()
      ta.cbSize = sizeof ta;
      GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), 0, &ta);
      HDC wh = GetDC(0);
        CreateFontW(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ta.FaceName));
      WCHAR xr = 0xFFFD;
      WORD zu[1];
      GetGlyphIndicesW(wh, &xr, 1, zu, 1);
      printf("%ls: %s\n", ta.FaceName, *zu == 0xFFFF ? "FAILURE" : "SUCCESS");


    DejaVu Sans Mono: SUCCESS
    Consolas: FAILURE

> On the other hand, during testing I saw a 0xfffd character printed for
> these fonts.  None of them actually supports 0xfffd, so apparently the
> Windows console already uses replacement fonts if possible.
> I guess I just stop here and always print 0xfffd.  I seriously doubt
> it makes sense to add so much code just to print a single char in a
> border case.

this is not possible; most likely you were seeing the ".notdef glyph":

for Consolas which is simlar in appearance to U+FFFD REPLACEMENT CHARACTER. The
differnce is that if you copy the ".notdef glyph" and paste it into "Notepad" or
similar, it will paste the proper character that couldnt be seen in the console,
while pasting U+FFFD into "Notepad" will just paste itself.

Expanding on the "Notepad" example, "Notepad" default font is "Lucida Console",
which doesnt have U+FFFD either. However pasting into "Notepad" will still show
U+FFFD properly because "Tahoma" has U+FFFD and "Notepad" can utilize composite
font, while it appears "cmd.exe" and similar cannot.

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list