Module: Locale::SystemWin32

Extended by:
SystemBase
Includes:
SystemWin32Table
Defined in:
lib/locale/win32.rb

Overview

Locale::SystemWin32 module for win32. This is a low-level class. Application shouldn’t use this directly.

Constant Summary collapse

@@default_locale =
Locale::Object.new("en", nil, "CP1252")
@@win32 =
Win32API.new("kernel32.dll", "GetUserDefaultLangID", nil, "i")

Constants included from SystemWin32Table

Locale::SystemWin32Table::LocaleTable

Class Method Summary collapse

Methods included from SystemBase

charset, locale_from_env, system

Class Method Details

.default_localeObject

:nodoc:



37
38
39
40
41
42
43
44
45
# File 'lib/locale/win32.rb', line 37

def default_locale  #:nodoc:
  lang = LocaleTable.assoc(@@win32.call)
  if lang
    ret = Locale::Object.new(lang[1], nil, lang[2])
  else
    ret = @@default_locale
  end
  ret
end

.get_charset(locale) ⇒ Object

Gets the Win32 charset of the locale.

  • locale: Locale::Object

  • Returns the charset of the locale



31
32
33
34
35
# File 'lib/locale/win32.rb', line 31

def get_charset(locale)
  loc = LocaleTable.find{|v| v[1] == locale.to_win}
  loc = LocaleTable.find{|v| v[1] =~ /^#{locale.language}-/} unless loc
  loc ? loc[2] : "CP1252"
end