[lsb@lsb.org: [EAI] (summary) display of RightToLeft chars in
localparts and hostnames]
Soobok Lee
lsb at lsb.org
Thu Dec 7 12:12:22 CET 2006
On Thu, Dec 07, 2006 at 10:12:31AM +0100, Harald Alvestrand wrote:
> I suppose it's possible to execute the whole bidi algorithm of UAX#9 and
> re-code the result as some kind of "normalized RTL". Is there a
> normalization algorithm for bidi in Unicode?
http://www.unicode.org/reports/tr9/BidiReferenceJava/
bidi.getReordering() seems to exist for such purpose, though
I am not sure.
(excerpts from BidiReferenceTest.java.txt)
/**
* Run the BidiReference algorithm over the string using the current character to direction code mapping.
*/
void runSample(String str) {
try {
byte[] codes = charmap.getCodes(str);
BidiReference bidi = new BidiReference(codes, baseDirection);
int[] reorder = bidi.getReordering(new int[] { codes.length });
writer.println("base level: " + bidi.getBaseLevel() + (baseDirection != -1 ? " (forced)" : ""));
// output original text
for (int i = 0; i < str.length(); ++i) {
displayChar(str.charAt(i));
}
writer.println();
// output visually ordered text
for (int i = 0; i < str.length(); ++i) {
displayChar(str.charAt(reorder[i]));
}
writer.println();
}
catch (Exception e) {
writer.println(e);
}
writer.println();
}
More information about the Idna-update
mailing list