Module: Tk::Encoding

Extended by:
Encoding
Included in:
Tk, Encoding
Defined in:
lib/tk.rb,
lib/tk.rb

Constant Summary collapse

TkCommandNames =
['encoding'.freeze].freeze

Instance Method Summary collapse

Instance Method Details

#encodingObject



2355
2356
2357
# File 'lib/tk.rb', line 2355

def encoding
  TkCore::INTERP.encoding
end

#encoding=(name) ⇒ Object



2351
2352
2353
# File 'lib/tk.rb', line 2351

def encoding=(name)
  TkCore::INTERP.encoding = name
end

#encoding_convertfrom(str, enc = None) ⇒ Object Also known as: encoding_convert_from



2371
2372
2373
2374
2375
2376
2377
2378
2379
# File 'lib/tk.rb', line 2371

def encoding_convertfrom(str, enc=nil)
  # str is an usual enc string or a Tcl's internal string expression
  # in enc (which is returned from 'encoding_convertto' method). 
  # the return value is a UTF-8 string.
  enc = encoding_system unless enc
  ret = TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str)
  ret.instance_variable_set('@encoding', 'utf-8')
  ret
end

#encoding_convertto(str, enc = None) ⇒ Object Also known as: encoding_convert_to



2382
2383
2384
2385
2386
2387
2388
2389
2390
# File 'lib/tk.rb', line 2382

def encoding_convertto(str, enc=nil)
  # str must be a UTF-8 string.
  # The return value is a Tcl's internal string expression in enc. 
  # To get an usual enc string, use Tk.fromUTF8(ret_val, enc).
  enc = encoding_system unless enc
  ret = TkCore::INTERP.__invoke('encoding', 'convertto', enc, str)
  ret.instance_variable_set('@encoding', 'binary')
  ret
end

#encoding_dirsObject



2393
2394
2395
2396
# File 'lib/tk.rb', line 2393

def encoding_dirs
  # Tcl8.5 feature
  TkComm.simplelist(Tk.tk_call_without_enc('encoding', 'dirs'))
end

#encoding_dirs=(dir_array) ⇒ Object

an array or a Tcl’s list string



2398
2399
2400
2401
# File 'lib/tk.rb', line 2398

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_namesObject



2359
2360
2361
# File 'lib/tk.rb', line 2359

def encoding_names
  TkComm.simplelist(Tk.tk_call('encoding', 'names'))
end

#encoding_systemObject



2363
2364
2365
# File 'lib/tk.rb', line 2363

def encoding_system
  Tk.tk_call('encoding', 'system')
end

#encoding_system=(enc) ⇒ Object



2367
2368
2369
# File 'lib/tk.rb', line 2367

def encoding_system=(enc)
  Tk.tk_call('encoding', 'system', enc)
end