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:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=XCiRXF0s02INRqEsNnKvwGEeGLXaPfdGZA/f/ukZJsGcRk/m6ljJp zvrEWrzUPttA74ENPg5ExFv9BPUoz9kKJlgNPdORbpEI09Rq2jDBKApZdKWKS5K5 lKDlv6o7lKLU1afMm8BvijaUKAZHZwxuc4qVI19W8PQaNfZqFQq0/E= 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:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=s01TaHjAK1CLlz7cPRPbI77cROk=; b=lw4MXrkNRvkrXX+HIMGGQtWTS9s6 MhDAK67/SVSo/1SLh4ChAfFjDVXNlwK74np6yx136N29EsC6OLLezX7pWy3zi83E MP6IIT5Hlysf7Oue76rI8z9QyPEeSCm1V/+hV1zC8l7Tn0pGKanKVHglWYCdaN2Q S4wNit3+kGcfurg= 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=-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 Date: Mon, 3 Sep 2018 23:02:58 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Cygwin fails to utilize Unicode replacement character Message-ID: <20180903210258.GC6350@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <5b8bdcc4 DOT 1c69fb81 DOT 84d1a DOT e6b9 AT mx DOT google DOT com> <20180903124616 DOT GT6350 AT calimero DOT vinschen DOT de> <20180903145919 DOT GU6350 AT calimero DOT vinschen DOT de> <126ebbde-2432-f19b-6c5c-fe61f31e4647 AT towo DOT net> <20180903171659 DOT GY6350 AT calimero DOT vinschen DOT de> <515ad501-3cb4-0236-ce03-0b7d9286bd24 AT towo DOT net> <20180903191437 DOT GZ6350 AT calimero DOT vinschen DOT de> <20180903202716 DOT GA6350 AT calimero DOT vinschen DOT de> <1575af94-78b3-681a-7dc1-0932969ac3e4 AT towo DOT 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) --8f0Rp8CLSOFvlIcd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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" -----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--