[lsb@lsb.org: [EAI] (summary) display of RightToLeft chars in
localparts and hostnames]
Soobok Lee
lsb at lsb.org
Thu Dec 7 12:55:07 CET 2006
On Thu, Dec 07, 2006 at 08:12:22PM +0900, Soobok Lee wrote:
> 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.
I find bidi.getReordering() is for Visual Reordering and not for RTL-normalization.
VisualOordering(codes) != RTL-nomalized(codes)
so bidi.getReordering() won't be directly usable for RTL normalization, but can be
the base code for such work.
Soobok
>
> (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