Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] Correctly pad date strings, as they might contain utf-8 characters
@ 2010-03-09 17:04 Michael Stapelberg
  2010-03-12  4:45 ` Rich Lane
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Stapelberg @ 2010-03-09 17:04 UTC (permalink / raw)
  To: sup-devel

[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [sup-devel] [PATCH] Correctly pad date strings, as they might contain utf-8 characters
  2010-03-09 17:04 [sup-devel] [PATCH] Correctly pad date strings, as they might contain utf-8 characters Michael Stapelberg
@ 2010-03-12  4:45 ` Rich Lane
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Lane @ 2010-03-12  4:45 UTC (permalink / raw)
  To: Michael Stapelberg; +Cc: sup-devel

Excerpts from Michael Stapelberg's message of 2010-03-09 12:04:27 -0500:
> 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

Thanks, applied directly to master.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-12  4:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-09 17:04 [sup-devel] [PATCH] Correctly pad date strings, as they might contain utf-8 characters Michael Stapelberg
2010-03-12  4:45 ` Rich Lane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox