土曜日, 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;

I2S プロトコル

I²S(Inter-IC Sound)は、マイコンやオーディオ機器間で音声データをやり取りするために設計された、シリアル通信プロトコルです。I²CやSPIと名前は似ていますが、I²Sは音声専用のプロトコルです。 I²Sは、以下の3つの主要な信号線を使って通信します。 BCLK (...