bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bulk] Re: Texinfo Windows patch: Non-ASCII text output


From: Jason Hood
Subject: Re: [Bulk] Re: Texinfo Windows patch: Non-ASCII text output
Date: Fri, 26 Dec 2014 11:44:26 +1000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 26/12/2014 2:00, Eli Zaretskii wrote:
> [...] when the output encoding,
> as determined by the current console codepage, is UTF-8 or UTF-7.  For
> these 2 encodings, the _only_ way of delivering text to the Windows
> console is by using the "wide" APIs, which accept UTF-16 encoded text.

Actually, the problem here is that cputs/cprintf output one character at
a time, not only making them really slow, but breaking UTF.  I would
suggest dropping those functions in Windows, using WriteConsoleA
instead.  This would be something along the lines of:

// pc_put_text (string)

  if (speech_friendly)

    fputs (string, stdout);

  else
#ifdef __MINGW32__

  {
    DWORD written;
    WriteConsole (hscreen, string, strlen(string), &written, NULL);

  }
#else
    cputs (string);

#endif



// pc_write_chars (string, nchars)

  if (speech_friendly)

    printf ("%.*s", nchars, string);

  else
#ifdef __MINGW32__

  {
    DWORD written;
    WriteConsole (hscreen, string, nchars, &written, NULL);

  }
#else
    cprintf ("%.*s", nchars, string);

#endif

Then you can drop write_utf and output_cp.

> The patch also handles the calls to terminal_write_chars,
> which Jason's patch left out.

It wasn't used, so I didn't bother.  I'm guessing it's still not used,
otherwise you'd be dropping the last character (you should only do
wlen - 1 when nbytes == -1).

-- 
Jason.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]