aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib')
-rw-r--r--ext/tk/lib/multi-tk.rb8
-rw-r--r--ext/tk/lib/remote-tk.rb4
-rw-r--r--ext/tk/lib/tk.rb51
-rw-r--r--ext/tk/lib/tk/encodedstr.rb8
-rw-r--r--ext/tk/lib/tk/namespace.rb12
-rw-r--r--ext/tk/lib/tk/optiondb.rb2
-rw-r--r--ext/tk/lib/tk/spinbox.rb3
-rw-r--r--ext/tk/lib/tk/validation.rb3
8 files changed, 69 insertions, 22 deletions
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb
index 6d048e91bc..e8bbf67de1 100644
--- a/ext/tk/lib/multi-tk.rb
+++ b/ext/tk/lib/multi-tk.rb
@@ -1730,11 +1730,11 @@ class << MultiTkIp
__getip._invoke_with_enc(*args)
end
- def _toUTF8(str, encoding)
+ def _toUTF8(str, encoding=nil)
__getip._toUTF8(str, encoding)
end
- def _fromUTF8(str, encoding)
+ def _fromUTF8(str, encoding=nil)
__getip._fromUTF8(str, encoding)
end
@@ -2119,11 +2119,11 @@ class MultiTkIp
@interp._invoke_with_enc(*args)
end
- def _toUTF8(str, encoding)
+ def _toUTF8(str, encoding=nil)
@interp._toUTF8(str, encoding)
end
- def _fromUTF8(str, encoding)
+ def _fromUTF8(str, encoding=nil)
@interp._fromUTF8(str, encoding)
end
diff --git a/ext/tk/lib/remote-tk.rb b/ext/tk/lib/remote-tk.rb
index bb2a2c114a..ed7f75b336 100644
--- a/ext/tk/lib/remote-tk.rb
+++ b/ext/tk/lib/remote-tk.rb
@@ -321,11 +321,11 @@ class RemoteTkIp
_appsend(true, false, *args)
end
- def _toUTF8(str, encoding)
+ def _toUTF8(str, encoding=nil)
@interp._toUTF8(str, encoding)
end
- def _fromUTF8(str, encoding)
+ def _fromUTF8(str, encoding=nil)
@interp._fromUTF8(str, encoding)
end
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index 9daee2de54..4267b42a3e 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -309,19 +309,48 @@ if USE_TCLs_LIST_FUNCTIONS
def array2tk_list(ary, enc=nil)
return "" if ary.size == 0
+ sys_enc = TkCore::INTERP.encoding
+ sys_enc = TclTkLib.encoding_system unless sys_enc
+
+ dst_enc = (enc == nil)? sys_enc: enc
+
dst = ary.collect{|e|
if e.kind_of? Array
- array2tk_list(e, enc)
+ s = array2tk_list(e, enc)
elsif e.kind_of? Hash
tmp_ary = []
#e.each{|k,v| tmp_ary << k << v }
e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
- array2tk_list(tmp_ary, enc)
+ s = array2tk_list(tmp_ary, enc)
else
- _get_eval_string(e, enc)
+ s = _get_eval_string(e, enc)
+ end
+
+ if dst_enc != true && dst_enc != false
+ if (s_enc = s.instance_variable_get(:@encoding))
+ s_enc = s_enc.to_s
+ else
+ s_enc = sys_enc
+ end
+ dst_enc = true if s_enc != dst_enc
end
+
+ s
}
- TkCore::INTERP._merge_tklist(*dst)
+
+ if sys_enc && dst_enc
+ dst.map!{|s| _toUTF8(s)}
+ ret = TkCore::INTERP._merge_tklist(*dst)
+ if dst_enc.kind_of?(String)
+ ret = _fromUTF8(ret, dst_enc)
+ ret.instance_variable_set(:@encoding, dst_enc)
+ else
+ ret.instance_variable_set(:@encoding, 'utf-8')
+ end
+ ret
+ else
+ TkCore::INTERP._merge_tklist(*dst)
+ end
end
else
@@ -2163,6 +2192,15 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
=end
end
+ module TclTkLib
+ def self.encoding=(name)
+ TkCore::INTERP.encoding = name
+ end
+ def self.encoding
+ TkCore::INTERP.encoding
+ end
+ end
+
module Tk
module Encoding
extend Encoding
@@ -2231,6 +2269,9 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
Tk.encoding = 'utf-8'
Tk.encoding_system = 'utf-8'
else # NONE
+ if defined? DEFAULT_TK_ENCODING
+ Tk.encoding_system = DEFAULT_TK_ENCODING
+ end
begin
Tk.encoding = Tk.encoding_system
rescue StandardError, NameError
@@ -4153,7 +4194,7 @@ end
#Tk.freeze
module Tk
- RELEASE_DATE = '2005-06-24'.freeze
+ RELEASE_DATE = '2005-07-05'.freeze
autoload :AUTO_PATH, 'tk/variable'
autoload :TCL_PACKAGE_PATH, 'tk/variable'
diff --git a/ext/tk/lib/tk/encodedstr.rb b/ext/tk/lib/tk/encodedstr.rb
index aed0e7524e..797e514a4c 100644
--- a/ext/tk/lib/tk/encodedstr.rb
+++ b/ext/tk/lib/tk/encodedstr.rb
@@ -67,9 +67,13 @@ module Tk
def initialize(str, enc = nil)
super(str)
+ # @encoding = ( enc ||
+ # ((self.class::Encoding)?
+ # self.class::Encoding : Tk.encoding_system) )
@encoding = ( enc ||
- ((self.class::Encoding)?
- self.class::Encoding : Tk.encoding_system) )
+ ((self.class::Encoding)?
+ self.class::Encoding :
+ ((Tk.encoding)? Tk.encoding : Tk.encoding_system) ) )
end
attr_reader :encoding
diff --git a/ext/tk/lib/tk/namespace.rb b/ext/tk/lib/tk/namespace.rb
index e0ef7c39dd..85a94372b9 100644
--- a/ext/tk/lib/tk/namespace.rb
+++ b/ext/tk/lib/tk/namespace.rb
@@ -115,19 +115,19 @@ class TkNamespace < TkObject
# alias __tk_call_with_enc tk_call_with_enc
def tk_call(*args)
#super('namespace', 'eval', @namespace, *args)
- args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @namespace,
TkCore::INTERP._merge_tklist(*args))
end
def tk_call_without_enc(*args)
#super('namespace', 'eval', @namespace, *args)
- args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @namespace,
TkCore::INTERP._merge_tklist(*args))
end
def tk_call_with_enc(*args)
#super('namespace', 'eval', @namespace, *args)
- args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @namespace,
TkCore::INTERP._merge_tklist(*args))
end
@@ -159,19 +159,19 @@ class TkNamespace < TkObject
alias __tk_call_with_enc tk_call_with_enc
def tk_call(*args)
#super('namespace', 'eval', @fullname, *args)
- args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
def tk_call_without_enc(*args)
#super('namespace', 'eval', @fullname, *args)
- args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
def tk_call_with_enc(*args)
#super('namespace', 'eval', @fullname, *args)
- args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb
index fe79de123c..a806f3971d 100644
--- a/ext/tk/lib/tk/optiondb.rb
+++ b/ext/tk/lib/tk/optiondb.rb
@@ -44,7 +44,7 @@ module TkOptionDB
"can't call 'TkOptionDB.read_entries' on a safe interpreter"
end
- i_enc = Tk.encoding()
+ i_enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
unless f_enc
f_enc = i_enc
diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb
index fe50d85e43..ac84e06cb3 100644
--- a/ext/tk/lib/tk/spinbox.rb
+++ b/ext/tk/lib/tk/spinbox.rb
@@ -25,7 +25,8 @@ class TkSpinbox<TkEntry
[ ?w, TkComm.method(:window) ],
[ ?e, proc{|val|
- enc = Tk.encoding
+ #enc = Tk.encoding
+ enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
if enc
Tk.fromUTF8(TkComm::string(val), enc)
else
diff --git a/ext/tk/lib/tk/validation.rb b/ext/tk/lib/tk/validation.rb
index eeb0163ee4..6755eef05f 100644
--- a/ext/tk/lib/tk/validation.rb
+++ b/ext/tk/lib/tk/validation.rb
@@ -226,7 +226,8 @@ class TkValidateCommand
[ ?w, TkComm.method(:window) ],
[ ?e, proc{|val|
- enc = Tk.encoding
+ #enc = Tk.encoding
+ enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
if enc
Tk.fromUTF8(TkComm::string(val), enc)
else