Class: Yast::EncodingClass
- Inherits:
-
Module
- Object
- Module
- Yast::EncodingClass
- Defined in:
- ../../library/general/src/modules/Encoding.rb
Instance Method Summary (collapse)
-
- (Object) Encoding
Constructor does nothing in initial mode restores console encoding from /etc/sysconfig in normal mode.
-
- (String) GetCodePage(enc)
Get Code Page.
-
- (Object) GetEncLang
Get Encoding Language.
-
- (Boolean) GetUtf8Lang
Get UTF8 Language.
- - (Object) main
-
- (Object) Restore
Restore data to system.
-
- (void) SetEncLang(new_lang)
Set Encoding Language.
-
- (void) SetUtf8Lang(new_utf8)
Set UTF8 Language.
Instance Method Details
- (Object) Encoding
Constructor does nothing in initial mode restores console encoding from /etc/sysconfig in normal mode
151 152 153 154 |
# File '../../library/general/src/modules/Encoding.rb', line 151 def Encoding Restore() if !Stage.initial nil end |
- (String) GetCodePage(enc)
Get Code Page
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File '../../library/general/src/modules/Encoding.rb', line 132 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 |
- (Object) GetEncLang
Get Encoding Language
105 106 107 108 109 |
# File '../../library/general/src/modules/Encoding.rb', line 105 def GetEncLang ret = @lang Builtins.y2milestone("GetEncLang ret %1", ret) ret end |
- (Boolean) GetUtf8Lang
Get UTF8 Language
123 124 125 126 127 |
# File '../../library/general/src/modules/Encoding.rb', line 123 def GetUtf8Lang ret = @utf8 Builtins.y2milestone("GetUtf8Lang ret %1", ret) ret end |
- (Object) main
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 60 61 |
# File '../../library/general/src/modules/Encoding.rb', line 34 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 |
- (Object) Restore
Restore data to system
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 90 91 |
# File '../../library/general/src/modules/Encoding.rb', line 65 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"), "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 |
- (void) SetEncLang(new_lang)
This method returns an undefined value.
Set Encoding Language
96 97 98 99 100 101 |
# File '../../library/general/src/modules/Encoding.rb', line 96 def SetEncLang(new_lang) @lang = new_lang Builtins.y2milestone("SetEncLang %1", @lang) nil end |
- (void) SetUtf8Lang(new_utf8)
This method returns an undefined value.
Set UTF8 Language
114 115 116 117 118 119 |
# File '../../library/general/src/modules/Encoding.rb', line 114 def SetUtf8Lang(new_utf8) @utf8 = new_utf8 Builtins.y2milestone("SetUtf8Lang %1", @utf8) nil end |