Danh mục

professional perl programming wrox 2001 phần 10

Số trang: 120      Loại file: pdf      Dung lượng: 1.69 MB      Lượt xem: 8      Lượt tải: 0    
Jamona

Hỗ trợ phí lưu trữ khi tải xuống: 27,000 VND Tải xuống file đầy đủ (120 trang) 0
Xem trước 10 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Các văn bản bên ngoài dấu ngoặc kép có mức nhúng từ 0, trong khi các văn bản trong dấu ngoặc kép (thể hiện trong tất cả HOA và giả định là trong kịch bản tiếng Ả Rập) có một mức độ nhúng của 1. Mỗi cấp độ có một hướng mặc định được gọi là hướng nhúng.
Nội dung trích xuất từ tài liệu:
professional perl programming wrox 2001 phần 10 UnicodeSimpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com The text outside the quotes has an embedding level of 0, whereas the text within the quotes (shown in ALL CAPITALS and assumed to be in the Arabic script) has an embedding level of 1. Each level has a default direction called the embedding direction . This direction is L (left to right) if the level number is even and R (right to left) if the level number is odd. Every paragraph has a default embedding level, and thus a default direction associated with it. This is also called the b ase direction of the paragraph. For example: A paragraph with a beginning like this in the Latin script would have a default embedding level as Level 0, and hence its base direction would be left to right. What the bidi Algorithm Does The bidi algorithm uses all these formatting codes and embedding levels for analyzing text to decide how it should be rendered. Here is briefly how it goes about doing it: It breaks up the text into paragraphs by locating the paragraph separators. This is necessary ❑ because all the directional formatting codes are only effective within a paragraph. Furthermore this is where the base direction is set. The rest of the algorithm treats the text on a paragraph-by-paragraph basis. The directional character types and the explicit formatting codes are used to resolve all the ❑ levels of embedding in the text. The text is then broken up into lines, and the characters are re-ordered on a line-by-line basis ❑ for rendering on the screen. Y FL Perl and bidi Since Perl is a language frequently used for text processing, it is natural that Perl should have bidi AM capabilities. We have an implementation of the bidi algorithm on Linux that can be used by Perl. We require a C library named FriBidi, which is basically a free implementation of the bidi algorithm, written by Dov Grobgeld. A Perl module has also been written by the same author, acting as an TE interface to the C library and is available as FriBidi-0.03.tar.gz from http://imagic.weizmann.ac.il/~dov/freesw/FriBidi . The FriBidi module enables us to do the following: Convert an ISO 8859-8 string to a FriBidi Unicode string: ❑ iso8859_8_to_unicode($string); Perform a logical to visual transformation. In other words, run the string obtained above ❑ through the bidi algorithm: log2vis($UniString, $optionalBaseDirection); This calculates the base direction if not passed as the second argument, returns the re-ordered string in scalar context, and additionally returns the base direction as the second element of the list in an array context. 1053 Team-Fly® Chapter 25Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Convert the string obtained above to an ISO 8859-8 character set: ❑ unicode_to_iso8859_8($toDisplay); This makes sure that it is in a ready-to-display format, assuming the terminal can display ISO 8859-8 characters (such as xterm). Translate a string from a FriBidi Unicode string to capRTL and vice versa: ❑ caprtl_to_unicode($capRTLString); unicode_to_caprtl($fribidiString); The capRTL format is where the CAPITAL LETTERS are mapped as having a strong right to left character property (RTL). This format is frequently used for illustrating bidi properties on displays with limited ability, such as ASCII-only displays. The following is a small example to demonstrate FriBidis capabilities. First, we create a small file with the following text, named bidisample: THUS, SAID THE CAMEL TO THE MEN, ...there is more than one way to do it. AND THE MEN REPLIED ...now we see what you mean by bidi, ...

Tài liệu được xem nhiều: