Module: Locale::Driver::Win32

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

Constant Summary collapse

@@win32 =
nil
@@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.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/locale/driver/win32.rb', line 35

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:



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/locale/driver/win32.rb', line 64

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:



59
60
61
62
# File 'lib/locale/driver/win32.rb', line 59

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

.thread_locale_idObject

:nodoc:



50
51
52
53
54
55
56
57
# File 'lib/locale/driver/win32.rb', line 50

def thread_locale_id  #:nodoc:
  if @@current_locale_id
    @@current_locale_id
  else
    @@win32 ||= Win32API.new("kernel32.dll", "GetThreadLocale", nil, "i")
    @@win32.call
  end
end