Re: [dev] [PATCH] Replace character with U+FFFD if wcwidth() is -1
On Tue, Oct 28, 2014 at 12:54 PM, Dmitrij D. Czarkoff
<czarkoff_AT_gmail.com> wrote:
> Helpful when new Unicode codepoints are not recognized by libc.
I do agree that this is the right approach. There is however another
instance of a wcwidth call on line st.c:3443 that should be handled as
well (maybe with abs in that particular case?).
> ---
> st.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/st.c b/st.c
> index 23dd7f1..ad52280 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -2576,7 +2576,10 @@ tputc(char *c, int len) {
> unicodep = ascii = *c;
> } else {
> utf8decode(c, &unicodep, UTF_SIZ);
> - width = wcwidth(unicodep);
> + if ((width = wcwidth(unicodep)) == -1) {
> + c = "\357\277\275"; /* UTF_INVALID */
> + width = 1;
> + }
> control = ISCONTROLC1(unicodep);
> ascii = unicodep;
> }
> --
> 2.1.2
>
>
Received on Tue Oct 28 2014 - 14:37:09 CET
This archive was generated by hypermail 2.3.0
: Tue Oct 28 2014 - 14:48:08 CET