From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/ext/tk/sample/demos-en/tkencoding.rb | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 jni/ruby/ext/tk/sample/demos-en/tkencoding.rb (limited to 'jni/ruby/ext/tk/sample/demos-en/tkencoding.rb') diff --git a/jni/ruby/ext/tk/sample/demos-en/tkencoding.rb b/jni/ruby/ext/tk/sample/demos-en/tkencoding.rb new file mode 100644 index 0000000..727491a --- /dev/null +++ b/jni/ruby/ext/tk/sample/demos-en/tkencoding.rb @@ -0,0 +1,42 @@ +# -*- ruby -*- +# +# tkencoding.rb +# written by ttate@jaist.ac.jp + +class TclTkIp + alias __eval _eval + alias __invoke _invoke + private :__eval + private :__invoke + + attr_accessor :encoding + + def _eval(cmd) + if( @encoding ) + _fromUTF8(__eval(_toUTF8(cmd,@encoding)),@encoding) + else + __eval(cmd) + end + end + + def _invoke(*cmds) + if( @encoding ) + cmds = cmds.collect{|cmd| _toUTF8(cmd,@encoding)} + _fromUTF8(__invoke(*cmds),@encoding) + else + __invoke(*cmds) + end + end +end + +module Tk + INTERP = TkCore::INTERP + + def encoding=(name) + INTERP.encoding = name + end + + def encoding + INTERP.encoding + end +end -- cgit v1.2.3