New Bidi APIs
In Eclipse 3.2, new APIs were added to provide proper rendering of strings containing bidirectional text that have implicit left to right semantic meaning. The method org.eclipse.osgi.util.TextProcessor.process(String str, String delimiter) provides this function.
- the string to process
- a string of characters used to segment the string.
The text of each segment has directional markers inserted at the beginning and end of it to ensure the entire string is rendered left-to-right and also has the Unicode Bidirectional algorithm applied to it in order to render the mixed text of the segment in the proper orientation.
As an example, a file path such as
(where capital letters indicate RTL-oriented text) should render as
when using the Unicode Bidi algorithm and segmenting the string according to a specified delimiter set. However, since the OS does not understand that the string should be segmented according to each segment of the file path, it uses the Bidirectional algorithm to renders the string as follows:
Types of strings to which this API should be applied are:
- File paths (e.g. d:\myFolder\abc\DEF)
- URLs (e.g. http://abc/DEF )
- File names with extensions (e.g. ABC.java)
- File associations (e.g. *.java, *.ABC)
To use the API, determine what delimiter characters should be used to segment the string, then simply call TextProcessor.process(string, delimiter);
The delimiter string for a file path would be "/\:." to account for volume separator (:), path separators (/ and \) and file extension separator (.).
The delimiter string for a URL would be ":/".
The Eclipse Platform has begun to use this API in the Eclipse 3.3 development stream. Examples of places where it is currently being used are the Info property page (for paths), the Properties view (for paths and file names with extensions), and the Navigator view (also for file names with extensions).
It has been suggested that APIs be provided for the most common usages so that users won't have to figure out for themselves the most common usages of this API (see bug 146220).