diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-05 05:56:31 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-07-05 05:56:31 +0000 |
commit | e3849ae9878e78fd089d117f5bd2cb787a62e941 (patch) | |
tree | 4eb42beb78e9a7d85198c12948ac76486ccd4818 /ext/tk/lib/tk.rb | |
parent | 6556fb4f00f041e06cd53ca4eab20967c02ffee8 (diff) |
* ext/tk/tcltklib.c: bug fix on treating Unicode strings.
* ext/tk/tcltklib.c: add methods to treat encoding mode.
* ext/tk/MANUAL_tcltklib.eng: add description of TclTkLib#encoding,
encoding_system, and so on.
* ext/tk/MANUAL_tcltklib.eucj: ditto.
* ext/tk/tkutil/tkutil.c: fail to create a Tcl's list string from
an array including multiple kind of encoded strings.
* ext/tk/lib/tk.rb: ditto.
* ext/tk/lib/multi-tk.rb: 2nd arg of _{to|from}UTF8 is omissible.
* ext/tk/lib/remote-tk.rb: ditto.
* ext/tk/lib/tk.rb: override TclTkLib#encoding and encoding= to
use TkCore::INTERP.encoding and encoding=.
* ext/tk/lib/tk.rb: when "require 'tk'" and $KCODE=='NONE', check
DEFAULT_TK_ENCODING to decide Ruby/Tk's system encoding mode.
* ext/tk/lib/tk/encodedstr.rb: check both of Tk.encoding and
Tk.encoding_system. Tk.encoding has higher priority.
* ext/tk/lib/tk/optiondb.rb: ditto.
* ext/tk/lib/tk/spinbox.rb: ditto.
* ext/tk/lib/tk/validation.rb: ditto.
* ext/tk/lib/tk/namespace.rb: arguemnts for TclTkIp#_merge_tklist
should be UTF-8 strings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tk.rb')
-rw-r--r-- | ext/tk/lib/tk.rb | 51 |
1 files changed, 46 insertions, 5 deletions
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' |