module Tk::Encoding - tk-0.2.0 Documentation

# module 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()
Alias for: encoding_name
default_encoding=(enc) click to toggle source

    # File lib/tk.rb, line 2720
    def default_encoding=(enc)
      TkCore::INTERP.default_encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
    end

encoding()
Alias for: encoding_name
encoding=(enc) click to toggle source

    # File lib/tk.rb, line 2724
    def encoding=(enc)
      TkCore::INTERP.encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
    end

encoding_convert_from(str, enc=nil)
Alias for: encoding_convertfrom
encoding_convert_to(str, enc=nil)
Alias for: encoding_convertto
encoding_convertfrom(str, enc=nil) click to toggle source

    # File lib/tk.rb, line 2819
    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 lib/tk.rb, line 2843
    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 lib/tk.rb, line 2857
    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 lib/tk.rb, line 2862
    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 lib/tk.rb, line 2728
    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 lib/tk.rb, line 2741
    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 lib/tk.rb, line 2731
    def encoding_obj
      Tk::Encoding::ENCODING_TABLE.get_obj(TkCore::INTERP.encoding)
    end

encoding_objs() click to toggle source

    # File lib/tk.rb, line 2746
    def encoding_objs
      self.tk_encoding_names.map!{|name|
        Tk::Encoding::ENCODING_TABLE.get_obj(name) rescue nil
      }.compact
    end

encoding_system()
Alias for: encoding_system_name
encoding_system=(enc) click to toggle source

    # File lib/tk.rb, line 2752
    def encoding_system=(enc)
      TclTkLib.encoding_system = Tk::Encoding::ENCODING_TABLE.get_name(enc)
    end

encoding_system_name() click to toggle source

    # File lib/tk.rb, line 2756
    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 lib/tk.rb, line 2759
    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 lib/tk.rb, line 2712
    def force_default_encoding(mode)
      TkCore::INTERP.force_default_encoding = mode
    end

force_default_encoding=(mode) click to toggle source

Ruby 1.8-

    # File lib/tk.rb, line 2769
    def force_default_encoding=(mode)
      true
    end

force_default_encoding?() click to toggle source

    # File lib/tk.rb, line 2716
    def force_default_encoding?
      TkCore::INTERP.force_default_encoding?
    end

tk_encoding_names() click to toggle source

    # File lib/tk.rb, line 2737
    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