From: wmorgan-sup@masanjin.net (William Morgan)
Subject: [sup-talk] the proper way of determining the encoding
Date: Wed, 09 Jan 2008 10:00:53 -0800 [thread overview]
Message-ID: <1199901555-sup-2661@south> (raw)
In-Reply-To: <1199695733-sup-2741@clarabella.clarabella>
Excerpts from Giorgio Lando's message of Mon Jan 07 00:51:08 -0800 2008:
> I understand. May be the encoding problems are so intricate and
> heterogeneous that they could be worth a configuration option, so the
> user can in anyway force a certain encoding if needed/desired?
I'm certainly happy to allow users to force a certain encoding, but I
think largely issue of encoding problems HAS been solved (at least on
Unixes) by locale and all the LC_* environment variables. I'm certainly
not an export on this stuff, though.
I just committed the following terrible patch to next, which should
properly find everyone's locale, if they have a locale. Mac users, I'd
love to know if this actually works for you.
commit 6af3048fe82f48f0368a619ea785f0a394b0bbd4
Author: William Morgan <wmorgan-sup at masanjin.net>
Date: Wed Jan 9 08:30:30 2008 -0800
detect character set correctly (but unix-centrically)
diff --git a/lib/sup.rb b/lib/sup.rb
index 25809dd..5bb27ba 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -49,16 +49,6 @@ module Redwood
YAML_DOMAIN = "masanjin.net"
YAML_DATE = "2006-10-01"
-## determine encoding and character set
-## probably a better way to do this
- $ctype = ENV["LC_CTYPE"] || ENV["LANG"] || "en-US.utf-8"
- $encoding =
- if $ctype =~ /\.(.*)?/
- $1
- else
- "utf-8"
- end
-
## record exceptions thrown in threads nicely
def reporting_thread name
if $opts[:no_threads]
@@ -235,6 +225,16 @@ module Redwood
module_function :log
end
+## determine encoding and character set. there MUST be a better way to
+## do this.
+ $encoding = `locale -c LC_CTYPE|head -6|tail -1`.chomp
+ if $encoding
+ Redwood::log "using character set encoding #{$encoding.inspect}"
+ else
+ Redwood::log "warning: can't find character set by using locale, defaulting
+ $encoding = "utf-8"
+ end
+
## now everything else (which can feel free to call Redwood::log at load time)
require "sup/update"
require "sup/suicide"
--
William <wmorgan-sup at masanjin.net>
next prev parent reply other threads:[~2008-01-09 18:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-05 21:46 Giorgio Lando
2008-01-07 6:04 ` William Morgan
2008-01-07 8:44 ` Giorgio Lando
2008-01-07 8:51 ` Giorgio Lando
2008-01-09 18:00 ` William Morgan [this message]
2008-01-10 0:39 ` Giorgio Lando
2008-01-13 2:22 ` William Morgan
2008-01-13 13:09 ` Giorgio Lando
2008-01-15 16:30 ` Grant Hollingworth
2008-01-16 1:45 ` William Morgan
2008-01-16 2:20 ` Nicolas Pouillard
2008-01-16 2:57 ` William Morgan
2008-01-16 3:09 ` William Morgan
2008-01-16 8:51 ` Nicolas Pouillard
2008-01-16 3:14 ` Nicolas Pouillard
2008-01-16 3:23 ` William Morgan
2008-01-16 3:28 ` Nicolas Pouillard
2008-01-16 3:38 ` William Morgan
2008-01-16 8:46 ` Nicolas Pouillard
2008-01-18 16:40 ` Nicolas Pouillard
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=1199901555-sup-2661@south \
--to=wmorgan-sup@masanjin.net \
/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