Class: Yast::EncodingClass
- Inherits:
-
Module
- Object
- Module
- Yast::EncodingClass
- Defined in:
- library/general/src/modules/Encoding.rb
Instance Method Summary collapse
-
#Encoding ⇒ Object
Constructor does nothing in initial mode restores console encoding from /etc/sysconfig in normal mode.
-
#GetCodePage(enc) ⇒ String
Get Code Page.
-
#GetEncLang ⇒ Object
Get Encoding Language.
-
#GetUtf8Lang ⇒ Boolean
Get UTF8 Language.
- #main ⇒ Object
-
#Restore ⇒ Object
Restore data to system.
-
#SetEncLang(new_lang) ⇒ void
Set Encoding Language.
-
#SetUtf8Lang(new_utf8) ⇒ void
Set UTF8 Language.
Instance Method Details
#Encoding ⇒ Object
Constructor does nothing in initial mode restores console encoding from /etc/sysconfig in normal mode
149 150 151 152 |
# File 'library/general/src/modules/Encoding.rb', line 149 def Encoding Restore() if !Stage.initial nil end |
#GetCodePage(enc) ⇒ String
Get Code Page
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'library/general/src/modules/Encoding.rb', line 130 def GetCodePage(enc) code = Ops.get_string(@enc_map, enc, "") if Builtins.size(code) == 0 && !@lang.nil? l = Builtins.substring(@lang, 0, 5) code = Ops.get_string(@lang_map, l, "") end Builtins.y2milestone( "GetCodePage enc %1 lang %2 ret %3", enc, @lang, code ) code end |
#GetEncLang ⇒ Object
Get Encoding Language
103 104 105 106 107 |
# File 'library/general/src/modules/Encoding.rb', line 103 def GetEncLang ret = @lang Builtins.y2milestone("GetEncLang ret %1", ret) ret end |
#GetUtf8Lang ⇒ Boolean
Get UTF8 Language
121 122 123 124 125 |
# File 'library/general/src/modules/Encoding.rb', line 121 def GetUtf8Lang ret = @utf8 Builtins.y2milestone("GetUtf8Lang ret %1", ret) ret end |
#main ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'library/general/src/modules/Encoding.rb', line 32 def main textdomain "base" Yast.import "Stage" # Current (ISO) encoding @console = "ISO-8859-1" @lang = "en_US" @utf8 = true @enc_map = { "euc-jp" => "932", "sjis" => "932", "gb2312" => "936", "iso8859-2" => "852", "big5" => "950", "euc-kr" => "949" } @lang_map = { "ja_JP" => "932", "zh_CN" => "936", "zh_TW" => "950", "zh_HK" => "950", "ko_KR" => "949" } Encoding() end |
#Restore ⇒ Object
Restore data to system
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'library/general/src/modules/Encoding.rb', line 63 def Restore @console = Convert.to_string( SCR.Read(path(".sysconfig.console.CONSOLE_ENCODING")) ) @console = "" if @console.nil? m = Convert.to_map( SCR.Execute(path(".target.bash_output"), "/usr/bin/locale -k charmap") ) m = {} if m.nil? out = Builtins.splitstring(Ops.get_string(m, "stdout", ""), "\n") Builtins.y2milestone("list %1", out) out = Builtins.filter(out) { |e| Builtins.find(e, "charmap=") == 0 } Builtins.y2milestone("list %1", out) if Ops.greater_than(Builtins.size(Ops.get(out, 0, "")), 0) enc = Builtins.substring(Ops.get(out, 0, ""), 8) Builtins.y2milestone("enc %1", enc) enc = Builtins.deletechars(enc, "\" ") Builtins.y2milestone("enc %1", enc) @console = enc if Ops.greater_than(Builtins.size(enc), 0) end Builtins.y2milestone("encoding %1", @console) @console end |
#SetEncLang(new_lang) ⇒ void
This method returns an undefined value.
Set Encoding Language
94 95 96 97 98 99 |
# File 'library/general/src/modules/Encoding.rb', line 94 def SetEncLang(new_lang) @lang = new_lang Builtins.y2milestone("SetEncLang %1", @lang) nil end |
#SetUtf8Lang(new_utf8) ⇒ void
This method returns an undefined value.
Set UTF8 Language
112 113 114 115 116 117 |
# File 'library/general/src/modules/Encoding.rb', line 112 def SetUtf8Lang(new_utf8) @utf8 = new_utf8 Builtins.y2milestone("SetUtf8Lang %1", @utf8) nil end |