[PATCH 3/3] conhost: Detect DBCS code pages using lead byte comparison

Hugh McMaster hugh.mcmaster at outlook.com
Tue Nov 23 04:57:59 CST 2021


On Tue, 23 Nov 2021 at 07:41, Alexandre Julliard wrote:
>
> Hugh McMaster writes:
>
> > @@ -646,7 +647,8 @@ static HFONT select_font_config( struct console_config *config, unsigned int cp,
> >      lstrcpyW( config->face_name, lf->lfFaceName );
> >
> >      /* FIXME: use maximum width for DBCS codepages since some chars take two cells */
> > -    if (GetCPInfo( cp, &cpinfo ) && cpinfo.MaxCharSize > 1)
> > +    GetCPInfo( cp, &cpinfo );
> > +    if (memcmp( cpinfo.LeadByte, lead_bytes, sizeof(cpinfo.LeadByte) ))
> >          config->cell_width  = tm.tmMaxCharWidth;
>
> That seems like a roundabout way of doing it. Wouldn't
> cpinfo.MaxCharSize == 2 work as well?

Yes, it would. The docs warn against relying on MaxCharSize, but I
don't see any reason that would affect this usage.

"The function cannot use the size to distinguish an SBCS or a DBCS
from other character sets because of other factors, for example, the
use of ISCII or ISO-2022-xx code pages." [1]

[1] https://docs.microsoft.com/en-us/windows/win32/api/winnls/ns-winnls-cpinfo



More information about the wine-devel mailing list