for saving GC cost
ENCNAMES_CMD = ['encoding'.freeze, 'names'.freeze]
start of creating ENCODING_TABLE
# File tk/lib/tk.rb, line 2732 def default_encoding=(enc) TkCore::INTERP.default_encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc) end
# File tk/lib/tk.rb, line 2736 def encoding=(enc) TkCore::INTERP.encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc) end
# File tk/lib/tk.rb, line 2831 def encoding_convertfrom(str, enc=nil) enc = encoding_system_name unless enc str = str.dup if TkCore::WITH_ENCODING if str.kind_of?(Tk::EncodedString) str.__instance_variable_set('@encoding', nil) else str.instance_variable_set('@encoding', nil) end str.force_encoding('binary') else str.instance_variable_set('@encoding', 'binary') end ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertfrom', enc, str) if TkCore::WITH_ENCODING ret.force_encoding('utf-8') else Tk::UTF8_String.new(ret) end ret end
# File tk/lib/tk.rb, line 2855 def encoding_convertto(str, enc=nil) # str must be a UTF-8 string enc = encoding_system_name unless enc ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertto', enc, str) #ret.instance_variable_set('@encoding', 'binary') if TkCore::WITH_ENCODING #ret.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj('binary')) ret.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj(enc)) end ret end
# File tk/lib/tk.rb, line 2869 def encoding_dirs # Tcl8.5 feature TkComm.simplelist(Tk.tk_call_without_enc('encoding', 'dirs')) end
# File tk/lib/tk.rb, line 2874 def encoding_dirs=(dir_list) # an array or a Tcl's list string # Tcl8.5 feature Tk.tk_call_without_enc('encoding', 'dirs', dir_list) end
# File tk/lib/tk.rb, line 2740 def encoding_name Tk::Encoding::ENCODING_TABLE.get_name(TkCore::INTERP.encoding) end
# File tk/lib/tk.rb, line 2753 def encoding_names self.tk_encoding_names.find_all{|name| Tk::Encoding::ENCODING_TABLE.get_name(name) rescue false } end
# File tk/lib/tk.rb, line 2743 def encoding_obj Tk::Encoding::ENCODING_TABLE.get_obj(TkCore::INTERP.encoding) end
# File tk/lib/tk.rb, line 2758 def encoding_objs self.tk_encoding_names.map!{|name| Tk::Encoding::ENCODING_TABLE.get_obj(name) rescue nil }.compact end
# File tk/lib/tk.rb, line 2764 def encoding_system=(enc) TclTkLib.encoding_system = Tk::Encoding::ENCODING_TABLE.get_name(enc) end
# File tk/lib/tk.rb, line 2768 def encoding_system_name Tk::Encoding::ENCODING_TABLE.get_name(TclTkLib.encoding_system) end
# File tk/lib/tk.rb, line 2771 def encoding_system_obj Tk::Encoding::ENCODING_TABLE.get_obj(TclTkLib.encoding_system) end
Ruby 1.9
# File tk/lib/tk.rb, line 2724 def force_default_encoding(mode) TkCore::INTERP.force_default_encoding = mode end
Ruby 1.8-
# File tk/lib/tk.rb, line 2781 def force_default_encoding=(mode) true end