Support for bidirectional character Set Language (BiDi) during Java development

Source: Internet
Author: User
Tags abstract character set versions

What's BiDi?

The two-way character set language (i.e. BiDi) is defined by the consortium as follows:

A bidirectional character set language usually refers to text that can be written both from left to right (LTR) and from right to left (RTL). For example, Arabic and Hebrew text is usually written from right to left, but other character sets (such as Latin text) remain formatted from left to right. Of course, other languages, such as English, can also be written in both directions if they contain Arabic or Hebrew text abstracts. The main direction is usually called the global direction.

For the introduction of a new knowledge or technology, the author is usually accustomed to from the "What, why, who, how" several aspects to tell. That's what BiDi is, which is described in this section. Why you need to support BiDi is described in the next section. Then it focuses on what issues to consider as a Java software developer in support of BiDi, what to do to achieve BiDi support, and some common problem and resolution techniques.

Why need BiDi support

For people using a bidirectional character set, writing on paper will be a matter of planning skills for native text and other character set text, such as in mixed English. As shown below:

Cibara 中文版 Cibara

Cibara represents the Arabic character, and 中文版 is the English character. The writer needs the right to left book characters "a" "R" "A" "B" "I" "C", which becomes cibara on paper. Then you write English characters Chinese, which are displayed from left to right, which requires the writer to plan the appropriate whitespace to write the text, and then continue to display the Arabic characters below. Otherwise, there is not enough space to write so many words, or leave a blank to affect the overall structure of the document.

The advent of computers in bidirectional character sets should be a great boon, and the blank plan described above will no longer be a problem. When the computer switches to the BiDi text entry mode, for general bidirectional character set characters, such as Arabic text, the display will follow the global direction from right to left (RTL). When you need to enter English characters, the computer will automatically handle the display of English characters. The first character will be entered automatically to the left row, after the characters displayed in front of the right side of the character, the text will be entered first to the left, and the input cursor will always stay in the English entry of the rightmost, followed by the processing of text entry, and display. In this way the input will not be concerned about how much space the English text would occupy, and the English content remained in the direction from left to right (LTR). When the user needs to enter Arabic text, the Arabic character will automatically be placed to the left of the English content, the input cursor also follows to the left of the Arabic character, starts the normal right to left (RTL) the entry, and displays.

It would be impossible for computer software to be sold and used in regions that use bidirectional character sets, mainly in the Middle East, without BiDi support. Support for BiDi is also an important part of the software internationalization (globalization) standard and cannot be said to support the internationalization of software without BiDi support. The world's major software companies have to BiDi support as a product can be issued an important evaluation index.

In fact, support for BiDi is very much to consider, from the underlying BiDi algorithms (such as ICU4J), encoding (Unicode), storage, input method, and support to development tools. However, as a developer (this article is primarily for Java developers), there is no need to know much about the details of the underlying implementation. For different software graphics library, only need very little code level processing can realize to BiDi support. If the reader wants to learn more about the BiDi level of knowledge, terminology, such as logical order, visual order, and so on, you can refer to DEVELOPEWORKSS or other articles on the consortium.

Java 1.5 Support for BiDi

Different versions of the Java SDK support the BiDi. Examples of this article and snippets of code are primarily for JDK 1.5 versions.

Java provides two graphics libraries for AWT and Swing, and these two graphics libraries are different for BiDi support. The software's support for the BiDi presentation layer includes the transition of the entire software interface from LTR to RTL, as well as the layout of the controls. For example, ComboBox's drop-down arrows move from the left to the right, the layout of the text in the control, the text input, and so on.

Awt

AWT (Abstract windowing Toolkit), translated as an abstract window toolkit, is the basic tool provided by Java to build and set up a Java graphical user interface. This toolkit provides a set of interfaces that interact with the local graphical interface. There are one by one corresponding relationships between the graphical functions in AWT and the graphical functions provided by the operating system. When we use AWT to component graphical user interface, we are actually using the graphics library provided by the operating system. For BiDi, the text layout within the AWT component actually relies on the underlying operating system. In addition, the AWT component has many drawbacks to the layout of the controls required by BiDi, so Java software developers should not use AWT if they want to develop applications that support BiDi.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.