土曜日, 1月 19, 2008

Character.UnicodeBlock: To obtain the character set

In line with the InputContext article the other day to alter keyboard setting and the font range, I would like to present here the following code to obtain the character set and set the locale for the InputContext.

With the use of Character.UnicodeBlock.of(char), and the returned value of the UnicodeBlock information, the locale can be set -- manually. Suppose you have a JTextArea and the cursor is on the area of the text that you want to add some input.

Bopomofo (Zhuyin) is a set of alphabets that is universally used in Taiwan. In the following code, the character under the cursor is examined and the locale is set to Locale.TAIWAN if it is a Zhuyin character.


int pos=textArea.getCaretPosition();
String text=textArea.getText();
char ch=text.charAt(pos);
Character.UnicodeBlock block=Character.UnicodeBlock.of(ch);
Locale current=Locale.US;
if(block==Character.UnicodeBlock.BOPOMOFO)
current=Locale.TAIWAN;

Qt: 外部プログラムを起動する

  Qt/C++ のアプリは、外部へ直接アクセスできます。これはネットアプリでは不可能な Qt のメリットです。 外部プログラムを起動することもできます。QProcess::startDetached() を使うと独立したプロセスを立ち上げることができます。 この QProces...