From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71039 invoked by alias); 3 Sep 2018 21:03:04 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 71019 invoked by uid 89); 3 Sep 2018 21:03:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-100.4 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=dejavu, DejaVu, courier X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Sep 2018 21:03:02 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MS2e2-1gLjDt3eBu-00TFa5 for ; Mon, 03 Sep 2018 23:02:59 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id E4430A820B4; Mon, 3 Sep 2018 23:02:58 +0200 (CEST) Date: Mon, 03 Sep 2018 21:03:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Cygwin fails to utilize Unicode replacement character Message-ID: <20180903210258.GC6350@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <5b8bdcc4.1c69fb81.84d1a.e6b9@mx.google.com> <20180903124616.GT6350@calimero.vinschen.de> <20180903145919.GU6350@calimero.vinschen.de> <126ebbde-2432-f19b-6c5c-fe61f31e4647@towo.net> <20180903171659.GY6350@calimero.vinschen.de> <515ad501-3cb4-0236-ce03-0b7d9286bd24@towo.net> <20180903191437.GZ6350@calimero.vinschen.de> <20180903202716.GA6350@calimero.vinschen.de> <1575af94-78b3-681a-7dc1-0932969ac3e4@towo.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8f0Rp8CLSOFvlIcd" Content-Disposition: inline In-Reply-To: <1575af94-78b3-681a-7dc1-0932969ac3e4@towo.net> User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-09/txt/msg00059.txt.bz2 --8f0Rp8CLSOFvlIcd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3668 On Sep 3 22:42, Thomas Wolff wrote: > Am 03.09.2018 um 22:27 schrieb Corinna Vinschen: > > On Sep 3 21:14, Corinna Vinschen wrote: > > > On Sep 3 20:20, Thomas Wolff wrote: > > > > Am 03.09.2018 um 19:56 schrieb Thomas Wolff: > > > > > Am 03.09.2018 um 19:16 schrieb Corinna Vinschen: > > > > > > On Sep=C2=A0 3 18:34, Thomas Wolff wrote: > > > > > > > Am 03.09.2018 um 16:59 schrieb Corinna Vinschen: > > > > > > > > Does anybody have an idea what I'm doing wrong? > > > > > > > This works in mintty, just uploaded a patch. Maybe somehow the > > > > > > > GetConsole > > > > > > > "dc" does not support this usage? > > > > > > =C2=AF\_(=E3=83=84)_/=C2=AF > > > > > Dito; hold on, sorry, your code does *not* work inside mintty. > > > > > Mine looks a bit different and I thought to have manually verifie= d it's > > > > > functionally equivalent, but indeed there must be something fishy= ... > > > > You still need to > > > > =C2=A0 SelectObject(cdc, f); > > > > where f is the HFONT of the font you want to check. > > > > To compare, you may check out function win_check_glyphs in file win= text.c in > > > > mintty. > > > Thanks but I don't know how to get a HFONT for the current console fo= nt. > > >=20 > > > In the meantime I figured out why my GetCurrentConsoleFontEx call > > > failed with error 87: > > >=20 > > > When looking again I realized there's a member called cbSize. The MS= DN > > > docs neglect to tell that the cbSize member has to be primed with > > > sizeof(CONSOLE_FONT_INFOEX). As soon as I tried that, the function > > > succeeded. > > >=20 > > > Well, it's a start. I now have the actual font name. No idea how to > > > get a HFONT from there, though. From what I can tell ATM, I'd have to > > > call CreateFont to get a new HFONT and then destroy it again after > > > usage. This looks pretty wasteful. > > Well, it still doesn't work for me. I now have the following code: > >=20 > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SNIP = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > [...] > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SNAP = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >=20 > > Supposedly none of the fonts support 0xfffd: > >=20 > > $ gcc -g -o cons cons.c -lgdi32 > > $ ./cons > > font Consolas > > gi =3D 65535 879 > > rp_idx =3D 1 > > $ ./cons > > font Lucida Console > > gi =3D 65535 620 > > rp_idx =3D 1 > > $ ./cons > > font Courier New > > gi =3D 65535 372 > > rp_idx =3D 1 > >=20 > > So I'm still doing something wrong, apparently. Any hint? > Test with a font that has the glyph; those 3 don't. Try DejaVu. I can't. I only have a limited set of fonts available in the console. But yes, you're right. 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. 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. Thanks a lot for your help, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --8f0Rp8CLSOFvlIcd Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAluNoYIACgkQ9TYGna5E T6DfPQ//fBRhi4m3PzixoL0W5tpjiToKI5A/aqteAy8Otmj8FxQeP619UW9feRWp sgEgmQymrgqCTZFg69Ag/V6zGvoHd1ns7lt92dIKAJABeNOZBMzSuxnsND4x+vTb 1saVg/9LBmCrJiPIIn/M81hTxLiUXEXTE66qAdR4TYsE5uKtYTvV1/wqREaoYaFm ZuBSe1VW+6zhYIHxgWnuU/KYm/QszUL+13wi11CDNNG/Z/OCOLEsmYe0ERttxrw4 4za/HIqLLvTviDH8Xt0bXPwAWulNyqwU6/ciyKsfkWo505/bSwQO4LA0awijGQUc mwoBLE/y2gl+LW4NdSQ14onrb+l5abjPlzvGHwR+DF9qxnP0yClfQkPxjpLTsDoL AaJtOCO1Em0dHw+CB+OqX9pxDmNDDwRZ3P1UO6imP8iqS5hxMyBemHoC4JHRBeG0 iZMC0uq9VMY3eJbmbPjWS3FsLWbpXhR+2CWxnqPgatiR3t3VfpXFHti1/A7eG5uv 8QnB8fLveuotb6B9WBdI/NxSQusgh9OLyaMeZJOfqRqa0MU9L8iNm5Hv5G6leWtT zJUmX3yxFdvrI1cHQqbE5C6Khtd+8DptiqZzv6WsM0B0ivLudLlgKHz2BVj2qmff 7utI9zNKqciXV3HCSVELvkdZgc3oKJsoZSnongwMPMEJ3M4ZE3c= =BTxY -----END PGP SIGNATURE----- --8f0Rp8CLSOFvlIcd--