<<< Date Index >>>     <<< Thread Index >>>

[PATCH] handle NBSP in pager (was Re: Spaces replaced by question marks?)



On Tue, Oct 05, 2010 at 10:34:42PM -0700, Morris, Patrick wrote:
On 10/5/2010 9:54 PM, Ed Blackman wrote:
Ah!  I didn't know that.  And indeed, they aren't 040 spaces:
0000000 123 165 172 151 145 054 012 240 012 124 150 151 163 040 145 155
         S   u   z   i   e   ,  nl  sp  nl   T   h   i   s  sp   e   m

240 instead of 040.

That should, indeed, be a non-breaking space (though I'm not shocked that a subject line with line breaks and non-breaking spaces in it would display strangely). Sounds like a bug.

Indeed, NBSP is not currently supported. The attached patch will convert NBSP to a normal space, but avoid breaking when $smart_wrap is set.

me
diff --git a/pager.c b/pager.c
--- a/pager.c
+++ b/pager.c
@@ -1187,10 +1187,17 @@
       last_special = special;
     }
 
-    if (IsWPrint (wc))
+    if (IsWPrint (wc) || (Charset_is_utf8 && wc == 0x00A0))
     {
       if (wc == ' ')
        space = ch;
+      else if (Charset_is_utf8 && wc == 0x00A0)
+      {
+       /* Convert non-breaking space to normal space. The local variable
+        * `space' is not set here so that the caller of this function won't
+        * attempt to wrap at this character. */
+       wc = ' ';
+      }
       t = wcwidth (wc);
       if (col + t > wrap_cols)
        break;