BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm...

143
BiDi in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer

Transcript of BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm...

Page 1: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

BiDi in the WildChallenges of the Unicode Bidirectional algorithm

Moriel Schottlender

Software Engineer

Page 2: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 3: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 4: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Wikipedia’sRight-to-Left support

Page 5: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Right-to-Left Wikipedias● ~260 Wikipedias in Left-to-Right

● ~17 Wikipedias in Right-to-Left

Page 6: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Right-to-Left Wikipedias● ~260 Wikipedias in Left-to-Right

● ~17 Wikipedias in Right-to-Left

Arabic Wikipedia ~1,000,000 users

~375,000 articles

Page 7: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Right-to-Left Wikipedias● ~260 Wikipedias in Left-to-Right

● ~17 Wikipedias in Right-to-Left

Arabic Wikipedia ~1,000,000 users

~375,000 articles

Persian Wikipedia ~514,000 users

~460,000 articles

Page 8: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Right-to-Left Wikipedias● ~260 Wikipedias in Left-to-Right

● ~17 Wikipedias in Right-to-Left

Arabic Wikipedia ~1,000,000 users

~375,000 articles

Persian Wikipedia ~514,000 users

~460,000 articles

Hebrew Wikipedia ~277,000 users

~175,000 articles

Page 9: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 10: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 11: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Editing Right-to-Left Wikipedias

Page 12: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

A brief history ofRight-to-Left support online

Page 13: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Long long ago● Computers mostly only knew Left to Right

● Supporting non-latin scripts required special fonts

● There was no real Right-to-Left support

Page 14: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Long long ago● Computers mostly only knew Left to Right

● Supporting non-latin scripts required special fonts

● There was no real Right-to-Left support

Solution:

Page 15: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Long long ago● Computers mostly only knew Left to Right

● Supporting non-latin scripts required special fonts

● There was no real Right-to-Left support

Solution: Writing backwards

Page 16: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Long long ago● Computers mostly only knew Left to Right

● Supporting non-latin scripts required special fonts

● There was no real Right-to-Left support

Solution: Writing backwards

Page 17: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Long long ago● Computers mostly only knew Left to Right

● Supporting non-latin scripts required special fonts

● There was no real Right-to-Left support

Solution: Writing backwards

enod eb ot dah gnihtemoS

Page 18: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Long long ago● Computers mostly only knew Left to Right

● Supporting non-latin scripts required special fonts

● There was no real Right-to-Left support

Solution: Writing backwards

Something had to be done

Page 19: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

● Visual: שלום עולם

● Logical: שלום עולם

Char order: 1 2 3 4

Char order: 4 3 2 1

Pre-BiDi Solution: Visual and Logical encoding

Page 20: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

● Visual: שלום עולם

● Logical: שלום עולם

1 2 3 4

4 3 2 1

(Someone had to type this backwards!)

Pre-BiDi Solution: Visual and Logical encoding

Char order:

Char order:

Page 21: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Pre-BiDi Solution: Visual and Logical encoding

● Visual: שלום עולם

● Logical: שלום עולם

Char order: 1 2 3 4

Char order: 4 3 2 1

(Someone had to type this backwards!)

Page 22: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

UnicodeBidirectionalAlgorithm

Page 23: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Unicode Bidirectional Algorithmhttp://unicode.org/reports/tr9/

If all text on a page is uniform (all RTL or all LTR) the ordering of the display text is

unambiguous.

Page 24: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Unicode Bidirectional Algorithmhttp://unicode.org/reports/tr9/

If all text on a page is uniform (all RTL or all LTR) the ordering of the display text is

unambiguous.

● RTL content can include digits (written LTR)

● RTL content can be mixed with LTR content

Page 25: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Unicode Bidirectional Algorithmhttp://unicode.org/reports/tr9/

If all text on a page is uniform (all RTL or all LTR) the ordering of the display text is

unambiguous.

● RTL content can include digits (written LTR)

● RTL content can be mixed with LTR content

Santa Claraב Unicode Conferenceאני הולכת להרצות בExamples:

צריך להתקשר ל 555-123-4567

Page 26: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Unicode Bidirectional Algorithmhttp://unicode.org/reports/tr9/

If all text on a page is uniform (all RTL or all LTR) the ordering of the display text is

unambiguous.

● RTL content can include digits (written LTR)

● RTL content can be mixed with LTR content

The Bidirectional Algorithm is meant to solve ambiguity in rendering order.

Santa Claraב Unicode Conferenceאני הולכת להרצות בExamples:

צריך להתקשר ל 555-123-4567

Page 27: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Quick primer to BiDi entity typesStrong

Weak

Neutral

Affect the directionality of entities around them

Do not affect the directionality of entities around them

Take the directionality of the context they’re in

Alphabet

Punctuation*, digits

Space, newline, tab, etc

http://unicode.org/reports/tr9/

Page 28: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbersעברית 123

Page 29: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

עברית 123

Numbers

RTL

LTR

Page 30: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

עברית 123

Numbers

RTL

עברית 1 23

LTR

RTL

LTR

(Whitespace is neutral)

Page 31: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

עברית 123

Numbers

RTL

עברית 1 23

LTR

RTL

LTR

(Whitespace is neutral)

עברית 1 2 3RTL

Page 32: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Text and numbersEnglish 1 2 3 Hebrew 1 2 3 English

Page 33: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

English 1 2 3 Hebrew 1 2 3 English

English 1 2 3 3 2 1 עברית English

Text and numbers

Page 34: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

English 1 2 3 Hebrew 1 2 3 English

English 1 2 3 3 2 1 עברית English

Weak WeakStrongStrong Strong

Text and numbers

Page 35: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

English 1 2 3 3 2 1 עברית English

LTR

Text and numbersEnglish 1 2 3 Hebrew 1 2 3 English

Weak WeakStrongStrong Strong

Page 36: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

English 1 2 3 3 2 1 עברית English

LTR RTL

Text and numbersEnglish 1 2 3 Hebrew 1 2 3 English

Weak WeakStrongStrong Strong

Page 37: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

English 1 2 3 3 2 1 עברית English

LTR RTL LTR

Text and numbersEnglish 1 2 3 Hebrew 1 2 3 English

Weak WeakStrongStrong Strong

Page 38: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

The confusing issueof the parentheses

Page 39: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

The confusing issueof the parenthesesDemo

Page 40: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

Page 41: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

(hello)

Page 42: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

(hello)

Page 43: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

(hello) (שלום)

Page 44: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

(hello) (שלום)

Page 45: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

Page 46: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

Good luck

with HTML

Page 47: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Parentheses

Good luck

with HTML

Or math

comparisons

Page 48: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

<a href="http://wikipedia.org" title="foo">bar</a>LTR

Page 49: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

<a href="http://wikipedia.org" title="foo">bar</a>LTR

RTL

<a href="http://wikipedia.org" title="foo">שלום</a>LTR

LTR

Page 50: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

<a href="http://wikipedia.org" title="אהלן">שלום</a>

<a href="http://wikipedia.org" title="foo">bar</a>LTR

RTL

<a href="http://wikipedia.org" title="foo">שלום</a>LTR

LTR

RTL

LTR

LTR

Page 51: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

<a href="http://wikipedia.org" title="אהלן">שלום</a>

<a href="http://wikipedia.org" title="foo">bar</a>LTR

RTL

<a href="http://wikipedia.org" title="foo">שלום</a>LTR

LTR

RTL

LTR

LTR

Page 52: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

RTL[[קובץ:Moriel schottlender.jpg|250px|שמאל|זו אני!]]

Page 53: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

RTL[[קובץ:Moriel schottlender.jpg|250px|שמאל|זו אני!]]

Page 54: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

[[קובץ:Moriel schottlender.jpg|250px|שמאל|זו אני!]]RTLLTR

RTL[[קובץ:Moriel schottlender.jpg|250px|שמאל|זו אני!]]

RTL

RTL

Page 55: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

[[קובץ:Moriel schottlender.jpg|250px|שמאל|זו אני!]]RTLLTR

RTL[[קובץ:Moriel schottlender.jpg|250px|שמאל|זו אני!]]

RTL

RTL

Page 56: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Your brain on BiDi

Credit: U.S. Navy photo by Photographer’s Mate 2nd Class Aaron Peterson. Public Domain.

https://commons.wikimedia.org/wiki/File:US_Navy_020712-N-5471P-010_EOD_teams_detonate_expired_ordnance_in_the_Kuwaiti_desert.jpg

Page 57: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

The tale of ananimated bitmap

Page 58: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

fig.bmp

Page 59: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

Page 60: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

#!/usr/bin/env pythonimport shutilshutil.copy("animated.gif", u"\u202Epmb.gif")

Code by David Chan

Page 61: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

#!/usr/bin/env pythonimport shutilshutil.copy("animated.gif", u"\u202Epmb.gif")

Code by David Chan

Page 62: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

#!/usr/bin/env pythonimport shutilshutil.copy("animated.gif", u"\u202Epmb.gif")

Code by David Chan

Page 63: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

#!/usr/bin/env pythonimport shutilshutil.copy("animated.gif", u"\u202Epmb.gif")

Code by David Chan

Page 64: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

#!/usr/bin/env pythonimport shutilshutil.copy("animated.gif", u"\u202Epmb.gif")

Code by David Chan

Page 65: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

#!/usr/bin/env pythonimport shutilshutil.copy("animated.gif", u"\u202Epmb.gif")

Code by David Chan

Page 66: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

\u202epmb.gif

fig.bmp

#!/usr/bin/env pythonimport shutilshutil.copy("animated.gif", u"\u202Epmb.gif")

Code by David Chan

Page 67: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Control characters● Implicit directional formatting

○ U+200E: LEFT-TO-RIGHT MARK (LRM)

○ U+200F: RIGHT-TO-LEFT MARK (RLM)

● Explicit directional embedding

○ U+202A: LEFT-TO-RIGHT EMBEDDING (LRE)

○ U+202B: RIGHT-TO-LEFT EMBEDDING (RLE)

○ U+202C: POP DIRECTIONAL FORMATTING (PDF)

● Explicit directional override

○ U+202D: LEFT-TO-RIGHT OVERRIDE (LRO)

○ U+202E: RIGHT-TO-LEFT OVERRIDE (RLO)

● Explicit directional isolate

○ U+2066: LEFT-TO-RIGHT ISOLATE

○ U+2067: RIGHT-TO-LEFT ISOLATE

○ U+2068: FIRST STRONG ISOLATE

○ U+2069: POP DIRECTIONAL ISOLATE

Page 68: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

When BiDi istechnically correctbut practically wrong

Page 69: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Solution: Force Isolation

Page 70: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Solution: Force Isolation

Page 71: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Solution: Force Isolation

Page 72: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Solution: Force Isolation

New topic created on [board name]: “<bdi>[topic title]</bdi>”

Page 73: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Solution: Force Isolation

New topic created on [board name]: “<bdi>[topic title]</bdi>”

Page 74: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

New topic created on [board name]: “<bdi>[topic title]</bdi>”

Solution: Force Isolation

Page 75: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Dates

Page 76: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Dates

Page 77: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Dates

TLV אל IST 28 במאי, 8:40

(TLV to IST 28 May, 8:40)

Page 78: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Dates

TLV אל IST 28 במאי, 8:40

LTRLTR RTLRTL

(TLV to IST 28 May, 8:40)

Page 79: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Dates

TLV אל IST 28 במאי, 8:40

LTRLTR RTLRTL

(TLV to IST 28 May, 8:40)

Page 80: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

Page 81: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

Page 82: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

Page 83: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

LTR client

Page 84: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

LTR client

RTL client

Page 85: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

LTR client

RTL client

Page 86: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

LTR client

RTL client

12

1 2

Page 87: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR email in RTL clients

LTR client

RTL client

12

1 2

Page 88: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

LTR client

RTL client

12

1 2

Solution: Always define content directionality

Page 89: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Applicationsimplement BiDiinconsistently

Page 90: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Web

Inconsistent implementation of BiDi (Facebook)

Page 91: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Web

Inconsistent implementation of BiDi (Facebook)

Maximum 2 Terms

Page 92: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Web

Mobile

Inconsistent implementation of BiDi (Facebook)

Maximum 2 Terms

Page 93: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Web

Mobile

Inconsistent implementation of BiDi (Facebook)

Maximum 2 Terms

Terms 2 Maximum

Page 94: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Web

Mobile

BiDi not

implemented???

Inconsistent implementation of BiDi (Facebook)

Maximum 2 Terms

Terms 2 Maximum

Page 95: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Inconsistent automatic detection of direction (Google Hangounts)

desktop

mobile

Page 96: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

desktop

mobile

Inconsistent automatic detection of direction (Google Hangounts)

Page 97: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

desktop

mobile

No auto-flip

auto-flip

auto-flipauto-flip

Inconsistent automatic detection of direction (Google Hangounts)

Page 98: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Even real lifeignores BiDi(and Unicode)a lot

Page 99: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 100: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 101: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

מסורת

Page 102: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

מסורת

سنت

Page 103: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 104: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

التقلید

Page 105: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

When BiDi itselfis confusing

Page 106: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Page 107: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Phone number 123-456-7890LTR

Page 108: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Phone number 123-456-7890LTR

RTLמספר טלפון 123-456-7890

Page 109: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Phone number 123-456-7890LTR Phone number +1-234-567-9012LTR

RTLמספר טלפון 123-456-7890

Page 110: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Phone number 123-456-7890LTR

RTLמספר טלפון +1-234-567-9012

Phone number +1-234-567-9012LTR

RTLמספר טלפון 123-456-7890

Plus / Minus signs are weak

Page 111: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Phone number 123-456-7890LTR

RTLמספר טלפון +1-234-567-9012

Phone number +1-234-567-9012LTR

RTLמספר טלפון 123-456-7890

There are 1-2 things but 4 - 5 othersLTR

Plus / Minus signs are weak

Page 112: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Phone number 123-456-7890LTR

RTLמספר טלפון +1-234-567-9012

Phone number +1-234-567-9012LTR

RTLמספר טלפון 123-456-7890

There are 1-2 things but 4 - 5 othersLTR

spaces

Plus / Minus signs are weak

Page 113: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Numbers, math and phone numbersNumbers are rendered Left-to-Right even in (most) Right-to-Left contexts

Phone number 123-456-7890LTR

RTLמספר טלפון +1-234-567-9012

Phone number +1-234-567-9012LTR

RTLמספר טלפון 123-456-7890

RTLיש 1-2 דברים אבל 4 - 5 אחרים

There are 1-2 things but 4 - 5 othersLTR

spaces

spaces (flipped)

Plus / Minus signs are weak

Page 114: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 115: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 116: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 117: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 118: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 119: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Printed in IsraelPrinted abroad

Page 120: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Bonus:Emoticons

Page 121: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Emoticons

:)LTR

(:RTL

Page 122: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Emoticons

:)LTR

(:RTL

:(LTR

):RTL

Page 123: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Emoticons

:)LTR

(:RTL

:(LTR

):RTL

:DLTR

D:RTL

:PLTR

P:RTL

Page 124: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Web

(Bonus fail)

Page 125: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Web

Android: Google SlidesAndroid: Google Drive

(Bonus fail)

Page 126: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

RTL UsersExpect nothing good

Page 127: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

RTL Usersare used to their computernot quite cooperating

Page 128: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 129: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 130: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left
Page 131: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Now what?

Page 132: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Now what?● Consistency in implementing the Bidirectional algorithm

Page 133: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Now what?● Consistency in implementing the Bidirectional algorithm

● Standard in predicting directionality while typing

Page 134: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Now what?● Consistency in implementing the Bidirectional algorithm

● Standard in predicting directionality while typing

● Improving isolation of numbers and dates

Page 135: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Now what?● Consistency in implementing the Bidirectional algorithm

● Standard in predicting directionality while typing

● Improving isolation of numbers and dates

● Consistent punctuation within sentences

(We solved “jumping” parentheses; let’s solve periods, commas, and colons!)

Page 136: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Remember Parentheses...MSchottlender (WMF)LTR

Page 137: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Remember Parentheses...MSchottlender (WMF)LTR

(MSchottlender (WMFRTL

Page 138: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Remember Parentheses...MSchottlender (WMF)LTR

(MSchottlender (WMFRTL

http://unicode.org/reports/tr9/#Paired_Brackets

Page 139: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Remember Parentheses...MSchottlender (WMF)LTR

(MSchottlender (WMFRTL

http://unicode.org/reports/tr9/#Paired_Brackets

Page 140: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Remember Parentheses...MSchottlender (WMF)LTR

(MSchottlender (WMFRTL

http://unicode.org/reports/tr9/#Paired_Brackets

Page 141: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Keep RTLing

Page 142: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Keep RTLinghttp://rtl.wtf

Page 143: BiDi in the Wild - Unicode Conference in the Wild Challenges of the Unicode Bidirectional algorithm Moriel Schottlender Software Engineer Wikipedia’s Right-to-Left support Right-to-Left

Keep RTLing ?snoitseuQhttp://rtl.wtf