In Files

  • tk/lib/tk.rb
  • tk/lib/tk/encodedstr.rb

Class/Module Index [+]

Quicksearch

Tk::Encoding

Constants

BINARY
BINARY_NAME
for saving GC cost

ENCNAMES_CMD = ['encoding'.freeze, 'names'.freeze]

DEFAULT_EXTERNAL_NAME
DEFAULT_INTERNAL_NAME
ENCODING_TABLE

start of creating ENCODING_TABLE

RubyEncoding
TkCommandNames
UNKNOWN
UTF8_NAME

Public Instance Methods

default_encoding() click to toggle source
Alias for: encoding_name
default_encoding=(enc) click to toggle source
 
               # File tk/lib/tk.rb, line 2732
def default_encoding=(enc)
  TkCore::INTERP.default_encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
end
            
encoding() click to toggle source
Alias for: encoding_name
encoding=(enc) click to toggle source
 
               # File tk/lib/tk.rb, line 2736
def encoding=(enc)
  TkCore::INTERP.encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
end
            
encoding_convert_from(str, enc=nil) click to toggle source
encoding_convert_to(str, enc=nil) click to toggle source
Alias for: encoding_convertto
encoding_convertfrom(str, enc=nil) click to toggle source
 
               # 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
            
Also aliased as: encoding_convert_from, encoding_convert_from
encoding_convertto(str, enc=nil) click to toggle source
 
               # 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
            
Also aliased as: encoding_convert_to, encoding_convert_to
encoding_dirs() click to toggle source
 
               # File tk/lib/tk.rb, line 2869
def encoding_dirs
  # Tcl8.5 feature
  TkComm.simplelist(Tk.tk_call_without_enc('encoding', 'dirs'))
end
            
encoding_dirs=(dir_list) click to toggle source
 
               # 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
            
encoding_name() click to toggle source
 
               # File tk/lib/tk.rb, line 2740
def encoding_name
  Tk::Encoding::ENCODING_TABLE.get_name(TkCore::INTERP.encoding)
end
            
Also aliased as: encoding, default_encoding, encoding, default_encoding
encoding_names() click to toggle source
 
               # 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
            
encoding_obj() click to toggle source
 
               # File tk/lib/tk.rb, line 2743
def encoding_obj
  Tk::Encoding::ENCODING_TABLE.get_obj(TkCore::INTERP.encoding)
end
            
encoding_objs() click to toggle source
 
               # 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
            
encoding_system() click to toggle source
encoding_system=(enc) click to toggle source
 
               # File tk/lib/tk.rb, line 2764
def encoding_system=(enc)
  TclTkLib.encoding_system = Tk::Encoding::ENCODING_TABLE.get_name(enc)
end
            
encoding_system_name() click to toggle source
 
               # File tk/lib/tk.rb, line 2768
def encoding_system_name
  Tk::Encoding::ENCODING_TABLE.get_name(TclTkLib.encoding_system)
end
            
Also aliased as: encoding_system, encoding_system
encoding_system_obj() click to toggle source
 
               # File tk/lib/tk.rb, line 2771
def encoding_system_obj
  Tk::Encoding::ENCODING_TABLE.get_obj(TclTkLib.encoding_system)
end
            
force_default_encoding(mode) click to toggle source

Ruby 1.9

 
               # File tk/lib/tk.rb, line 2724
def force_default_encoding(mode)
  TkCore::INTERP.force_default_encoding = mode
end
            
force_default_encoding=(mode) click to toggle source

Ruby 1.8-

 
               # File tk/lib/tk.rb, line 2781
def force_default_encoding=(mode)
  true
end
            
force_default_encoding?() click to toggle source
 
               # File tk/lib/tk.rb, line 2728
def force_default_encoding?
  TkCore::INTERP.force_default_encoding?
end
            
tk_encoding_names() click to toggle source
 
               # File tk/lib/tk.rb, line 2749
def tk_encoding_names
  #TkComm.simplelist(TkCore::INTERP._invoke_without_enc(Tk::Encoding::ENCNAMES_CMD[0], Tk::Encoding::ENCNAMES_CMD[1]))
  TkComm.simplelist(TkCore::INTERP._invoke_without_enc('encoding', 'names'))
end