Module: Locale::Driver::Win32

Includes:
Win32Table
Defined in:
lib/locale/driver/win32.rb

Defined Under Namespace

Modules: Kernel32

Constant Summary collapse

@@current_locale_id =
nil

Constants included from Win32Table

Locale::Driver::Win32Table::LocaleTable

Class Method Summary collapse

Class Method Details

.charsetObject

Gets the Win32 charset of the locale.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/locale/driver/win32.rb', line 48

def charset
  charset = ::Locale::Driver::Env.charset
  unless charset
    if locales
      tag = locales[0].to_rfc.to_s
      loc = LocaleTable.find{|v| v[1] == tag}
      loc = LocaleTable.find{|v| v[1] =~ /^#{locales[0].language}/} unless loc
      charset = loc ? loc[2] : nil
    else
      charset = "CP1252"
    end
  end
  charset
end

.localesObject

:nodoc:



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/locale/driver/win32.rb', line 76

def locales  #:nodoc:
  locales = ::Locale::Driver::Env.locales
  unless locales
    lang = LocaleTable.assoc(thread_locale_id)
    if lang
      ret = Locale::Tag::Common.parse(lang[1])
      locales = Locale::TagList.new([ret])
    else
      locales = nil
    end
  end
  locales
end

.set_thread_locale_id(lcid) ⇒ Object

:nodoc:



71
72
73
74
# File 'lib/locale/driver/win32.rb', line 71

def set_thread_locale_id(lcid)  #:nodoc:
  # for testing.
  @@current_locale_id = lcid
end

.thread_locale_idObject

:nodoc:



63
64
65
66
67
68
69
# File 'lib/locale/driver/win32.rb', line 63

def thread_locale_id  #:nodoc:
  if @@current_locale_id
    @@current_locale_id
  else
    Kernel32.GetThreadLocale
  end
end