1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/tk/sample/demos-jp/unicodeout.rb
matz a25fbe3b3e * encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.

* parse.y (pragma_encoding): encoding specification pragma.

* parse.y (rb_intern3): encoding specified symbols.

* string.c (rb_str_length): length based on characters.  
  for older behavior, bytesize method added.

* string.c (rb_str_index_m): index based on characters.  rindex as
  well.

* string.c (succ_char): encoding aware succeeding string.

* string.c (rb_str_reverse): reverse based on characters.

* string.c (rb_str_inspect): encoding aware string description.

* string.c (rb_str_upcase_bang): encoding aware case conversion.
  downcase, capitalize, swapcase as well.

* string.c (rb_str_tr_bang): tr based on characters.  delete,
  squeeze, tr_s, count as well.

* string.c (rb_str_split_m): split based on characters.

* string.c (rb_str_each_line): encoding aware each_line.

* string.c (rb_str_each_char): added.  iteration based on
  characters.

* string.c (rb_str_strip_bang): encoding aware whitespace
  stripping.  lstrip, rstrip as well.

* string.c (rb_str_justify): encoding aware justifying (ljust,
  rjust, center).

* string.c (str_encoding): get encoding attribute from a string. 

* re.c (rb_reg_initialize): encoding aware regular expression

* sprintf.c (rb_str_format): formatting (i.e. length count) based
  on characters.

* io.c (rb_io_getc): getc to return one-character string.
  for older behavior, getbyte method added.

* ext/stringio/stringio.c (strio_getc): ditto.

* io.c (rb_io_ungetc): allow pushing arbitrary string at the
  current reading point.

* ext/stringio/stringio.c (strio_ungetc): ditto.

* ext/strscan/strscan.c: encoding support.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00

117 lines
4 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: euc-jp -*-
#
# unicodeout.rb --
#
# This demonstration script shows how you can produce output (in label
# widgets) using many different alphabets.
#
# based on Tcl/Tk8.4.4 widget demos
if defined?($unicodeout_demo) && $unicodeout_demo
$unicodeout_demo.destroy
$unicodeout_demo = nil
end
$unicodeout_demo = TkToplevel.new {|w|
title("Unicode Label Demonstration")
iconname("unicodeout")
positionWindow(w)
}
TkLabel.new($unicodeout_demo,
:font=>$font, :wraplength=>'5.4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
Tkにおける非欧米文字集合を用いる言語に対するサポートについての\
\
\
\
\
\
Unicodeout_SampleFrameクラスの@@fontの定義を書き換えて\
()\
\\uXXXXという\
Tclのエスケープ表現を用いたUNICODE文字列で書かれています\
Tk::UTF8_Stringメソッドによって\
UTF8形式の文字列である\
\
(Tclのエスケープ表現の変換済み)\
EOL
#'
TkFrame.new($unicodeout_demo){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{
$unicodeout_demo.destroy
$unicodeout_demo = nil
}).pack(:side=>:left, :expand=>true)
TkButton.new(f, :text=>'コード参照', :width=>15, :command=>proc{
showCode 'unicodeout'
}).pack(:side=>:left, :expand=>true)
}
wait_msg = TkLabel.new($unicodeout_demo,
:text=>"フォント読み込みの完了まで" +
"しばらくお待ち下さい...",
:font=>"Helvetica 12 italic").pack
class Unicodeout_SampleFrame < TkFrame
@@font = $font
# @@font = 'Helvetica 14'
# @@font = 'Courier 12'
# @@font = 'clearlyu 16'
# @@font = 'fixed 12'
# @@font = 'Times 12'
# @@font = 'Newspaper 12'
# @@font = '{New century schoolbook} 12'
def initialize()
super($unicodeout_demo)
grid_columnconfig(1, :weight=>1)
end
def add_sample(lang, *args)
sample_txt = Tk::UTF8_String(args.join(''))
l = TkLabel.new(self, :font=>@@font, :text=>lang+':',
:anchor=>:nw, :pady=>0)
#s = TkLabel.new(self, :font=>@@font, :text=>sample_txt,
s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt,
:anchor=>:nw, :width=>30, :pady=>0)
Tk.grid(l, s, :sticky=>:ew, :pady=>0)
l.grid_config(:padx, '1m')
end
end
f = Unicodeout_SampleFrame.new
f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
# Processing when some characters are missing might take a while, so make
# sure we're displaying something in the meantime...
oldCursor = $unicodeout_demo.cursor
$unicodeout_demo.cursor('watch')
Tk.update
f.add_sample('Arabic',
'\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94',
'\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D')
f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57')
f.add_sample('Simpl. Chinese', '\u6C49\u8BED')
f.add_sample('Greek',
'\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ',
'\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1')
f.add_sample('Hebrew',
'\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ',
'\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9')
f.add_sample('Japanese',
'\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ',
'\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA')
f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00')
f.add_sample('Russian',
'\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ',
'\u044F\u0437\u044B\u043A')
wait_msg.destroy
$unicodeout_demo.cursor(oldCursor)