X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:to:subject:references :content-type; q=dns; s=default; b=S0JMrtHE5ga8v0gTkgELQeXylgYRc Db05YnT9rT13X7j+53IsXCJ9N/b/GiZmnI+6d2MJOwl625QOl30b9owQAxAZFP5M uJXFGecEAzDGAN1litmPVWw06o4eqGfHfB0cZVWBjJA1oQzezatqvKpHd10bGUoP mi/YHA83dX8Cq0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:to:subject:references :content-type; s=default; bh=yyR2PLyARdETBStsiPJypNVHkdU=; b=YXr gq+5dMQEFY+XVndovYwzK8GpAma79SEyi+WoO5vjuiS72JpV6F+9afDDycOBgruT f4K/cYA2lJ4wqXyZOq4giSm44Pisela+o6NsUvVQrSivd42rrZ44XnQDk22tpG9W Ks71vw1rPUii3DPTehqSRngLIvuuTUgmrr4yzt4o= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=sans, docs.microsoft.com, recom, sk:docs.mi X-HELO: mail-oi0-f66.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:to:subject:references:user-agent; bh=seCjSjw5C/F+SDjCHAMXgwtCXdrS/dsIiLnavOzHSG8=; b=u+ZYlQXtRDsYKPNvLJgI1c7dg2btEQygy3/aY6XcWvC3qp/CtTmJFZLfx4MSl8Px70 4P5KJhZMu8iSujrRmWrETaXNP/SCZWns7gR61fhyBnsGUFuqqjW4mswF6DXMjPfKMfJv Mvq56caYYkvQdW8ZjU+nlHBBZQXVV4jR1/Cr/ZyohxG8uOTDPAd7eFqoi/nYTYcG0max N67k5p+txDKo6i7WtMYN6P3gYFINxxILq/w8sXyqBBxtEI/WVXnY5DDdxj5o9Zpgss1S p+/PN3KSS0ICBOui2pEQsDmDey600w2ss+1ktjheZdCpQVHsoOLzCK135BvVrhi4NPIy ppIQ== Message-ID: <5b8db27e.1c69fb81.e3b47.6cd8@mx.google.com> Date: Mon, 03 Sep 2018 15:15:26 -0700 (PDT) From: Steven Penny To: cygwin AT cygwin DOT com Subject: Re: Cygwin fails to utilize Unicode replacement character References: <20180903210258 DOT GC6350 AT calimero DOT vinschen DOT de> Content-Type: text/plain; charset=utf8; format=flowed User-Agent: Tryst/2.8.0 (cup.github.io/tryst) 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. http://superuser.com/questions/390933/add-font-cmd-window-choices/956818 > 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 #include int main() { CONSOLE_FONT_INFOEX ta; ta.cbSize = sizeof ta; GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), 0, &ta); HDC wh = GetDC(0); SelectObject(wh, 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"); } Result: 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": http://docs.microsoft.com/typography/opentype/spec/recom 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: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple