Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Michael Stapelberg <michael+sup@stapelberg.de>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] [PATCH] Correctly pad date strings, as they might contain utf-8 characters
Date: Tue, 09 Mar 2010 18:04:27 +0100	[thread overview]
Message-ID: <1268154208-sup-7661@midna.zekjur.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Hi,

attached you find a patch for this problem. Quote of the commit message:

  sprintf is not utf8-aware and thus the output gets a wrong padding
  (correct in terms of bytes, not correct in terms of visible characters).
  You can notice this using a german locale (de_DE) and viewing mails
  from march (abbreviated "Mär" in german).

Best regards,
Michael

[-- Attachment #2: 0001-Correctly-pad-date-strings-as-they-might-contain-utf.patch --]
[-- Type: application/octet-stream, Size: 1479 bytes --]

From fe724f923cff437cbaaf227d3bfebfeba4a076cd Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Tue, 9 Mar 2010 18:01:49 +0100
Subject: [PATCH] Correctly pad date strings, as they might contain utf-8 characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

sprintf is not utf8-aware and thus the output gets a wrong padding
(correct in terms of bytes, not correct in terms of visible characters).
You can notice this using a german locale (de_DE) and viewing mails
from march (abbreviated "Mär" in german).
---
 lib/sup/modes/thread-index-mode.rb |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index f53001f..90bb80a 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -878,8 +878,11 @@ protected
 
     snippet = t.snippet + (t.snippet.empty? ? "" : "...")
 
-    size_widget_text = sprintf "%#{ @size_widget_width}s", size_widget
-    date_widget_text = sprintf "%#{ @date_widget_width}s", date_widget
+    size_padding = @size_widget_width - size_widget.display_length
+    size_widget_text = sprintf "%#{size_padding}s%s", "", size_widget
+
+    date_padding = @date_widget_width - date_widget.display_length
+    date_widget_text = sprintf "%#{date_padding}s%s", "", date_widget
 
     [ 
       [:tagged_color, @tags.tagged?(t) ? ">" : " "],
-- 
1.6.5


[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

             reply	other threads:[~2010-03-09 17:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09 17:04 Michael Stapelberg [this message]
2010-03-12  4:45 ` Rich Lane

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268154208-sup-7661@midna.zekjur.net \
    --to=michael+sup@stapelberg.de \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox