lib/locale/posix.rb in gettext-1.92.0 vs lib/locale/posix.rb in gettext-1.93.0
- old
+ new
@@ -4,19 +4,33 @@
Copyright (C) 2002-2007 Masao Mutoh
You may redistribute it and/or modify it under the same
license terms as Ruby.
- $Id: posix.rb,v 1.2 2007/11/08 16:44:22 mutoh Exp $
+ $Id: posix.rb,v 1.4 2008/09/15 16:32:39 mutoh Exp $
=end
require 'locale/base'
module Locale
# Locale::SystemPosix module for Posix OS (Unix)
# This is a low-level class. Application shouldn't use this directly.
module SystemPosix
extend SystemBase
+
+ module_function
+ # Gets the charset of the locale.
+ # * locale: Locale::Object
+ # * Returns the charset of the locale
+ def get_charset(locale)
+ charset = `LANG=#{locale.to_str};locale charmap`.strip
+ unless $? && $?.success?
+ charset = "UTF-8"
+ end
+ charset
+ end
end
+
@@locale_system_module = SystemPosix
+
end