[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [screen-devel] [PATCH] :hardcopy: handle encoding (Was: Hardcopy use
From: |
Alex Naumov |
Subject: |
Re: [screen-devel] [PATCH] :hardcopy: handle encoding (Was: Hardcopy uses ISO-8859-1) |
Date: |
Thu, 11 Feb 2016 00:44:02 +0100 |
Hi Simon,
first of all, thank you very much for this patch.
It takes a bit time: I just want to compare this code with our unicode++ branch.
Cheers,
Alex
On Sat, Feb 6, 2016 at 4:39 PM, Simon Ruderich <address@hidden> wrote:
> On Tue, Jan 26, 2016 at 02:46:29PM +0100, Simon Ruderich wrote:
>> Hi,
>>
>> I'm using GNU screen's hardcopy function to dump the current
>> screen content to a file. However the resulting file is encoded
>> in ISO-8859-1 although my current locale is UTF-8. This causes
>> corruption for characters which are not representable in
>> ISO-8859-1.
>
> Hello again,
>
> It's not actually using ISO-8859-1, but instead printing the
> first byte of ->image which seems to be the unicode code point.
>
> image.h:
> /* structure representing single cell of terminal */
> struct mchar {
> uint32_t image; /* actual letter like a, b, c ... */
> [...]
> };
>
> fileio.c WriteFile():
> for (i = 0; i < fore->w_height; i++) {
> p = fore->w_mlines[i].image;
> for (k = fore->w_width - 1; k >= 0 && p[k] == ' '; k--) ;
> for (j = 0; j <= k; j++)
> putc(p[j], f);
> putc('\n', f);
> }
>
> This obviously doesn't work for characters > 255 which caused the
> garbled display for me.
>
>
> The attached patch should fix the issue. However somebody should
> verify my assumptions:
>
> I'm not 100% sure that ->image is actually the unicode code
> point.
>
> Double-width characters are followed by a character with ->image
> = 0xff and ->font = 0xff. I assumed that this means the character
> is a filler character to handle the fixed screen width correctly,
> but I'm not entirely sure. Is there a function/constant to check
> for fillers like this? Hard-coding 0xff doesn't sound like a good
> idea.
>
> I don't know how the fontp parameter of EncodeChar() is used:
>
> int EncodeChar(char *bp, int c, int encoding, int *fontp)
>
> Passing NULL seems to work though.
>
> Regards
> Simon
>
> PS: The Git repository contains a lot of commits since the last
> release. A new release of GNU Screen sounds like a good idea to
> get those fixes/improvements distributed.
> --
> + privacy is necessary
> + using gnupg http://gnupg.org
> + public key id: 0x92FEFDB7E44C32F9