SlideShare a Scribd company logo
1 of 15
Download to read offline
Changes of Unicode Bidirectional
Algorithm at Unicode 6.3
Unicode Standard Annex #9
leejongsoo@gmail.com
Introduction
세상에는 다양한 ‘writing system’이 있습니다.
왼쪽에서 오른쪽으로 쓰기도 하고
고하 도기쓰 로으쪽왼 서에쪽른오
이 중 가장 많이 쓰이는 것은 왼쪽에서 오른쪽으로 쓰기입니다.
한글도 주로 그렇게 씁니다.
그러나 우리랑 다르게 사용하는 소수의 문화도 존중해야 합니다.
위
에
서
아
래
로
쓰
기
도
합
니
다
Not Right-to-Left, Bidirectional!
아래 언어들은 오른쪽에서 왼쪽으로 씁니다. 영어로는 ‘Right-to-Left’라고 해요.
- Arabic Script: Arabic, Persian, Urdu, …
- Hebrew Script: Hebrew, Yiddish
- Syriac Script: Syriac
- 그 외 여러가지 언어
근데 오른쪽에서 왼쪽 방향이 아니라 양방향일까요?
컴퓨터 세상에서는 영어와 같은 ‘Left-to-Right’ Script나 0,1,2,3과 같은 숫자와 함께
사용되는 것이 대부분이라서 ‘Bidirectional’, ‘양방향' 을 처리해줘야 합니다.
Unicode Annex #9 - UBA
Unicode 에서 요런 저런 부분을 보완하는 표준들이 있는데, Annex라고 부릅니다.
이 중에서 #9가 ‘Bidirectional Algorithm’에 대한 내용입니다.
UBA는 1998년 10월 30일에 최초로 만들어졌습니다.
그리고 2013년 9월 24일 Unicode 6.3에서 2 가지 중요한 개선이 이루어졌습니다.
1. Directional Isolation
2. Paired Brackes
Too many error!!! Why?
Unicode의 모든 문자들은 direction 정보를 가지고 있습니다.
‘a’는 L(eft-to-Right) 문자, ‘‫ل‬’는 R(ight-to-Left) 문자 그리고 공백 기호들은 ‘Neutral’
문자.
그리고 0,1 같은 숫자들은 방향성은 있지만 강하지는 않아서 ‘Weak’ 문자입니다.
모든 문제는 항상 불확실성에서 발생합니다.
즉, Neutral이나 Weak 같은 문자들이 문제를 만듭니다.
Error example
RTL 문단 중간에 LTR 이 있다고 하면… “RRRRR RRRR L(L) RRR RRRRRR”
기존의 알고리즘에서는 Weak 문자들은 자기 주변을 둘러싼 글자의 방향성을 따릅
니다.
따라서 ‘(‘는 L로 간주합니다.
L(L) => LLL?
문제는 ‘)’ 입니다. 해당 문단의 방향은 RTL이고 앞뒤로 LTR이 있는 것도 아니니 R
이 됩니다.
L(L) => LLLR
Error Case before Unicode 6.3
Programmer should be lazy.
사실 무식하지 않아도 평범하고 부지런한 사람이라면 문제를 해결하려 합니다.
부지런씨: ‘)L(L’ 로 잘못 나오는 것은 ‘L(L)’ 로 고쳐야죠.
그랬더니 화면에 똑바로 ‘L(L)’로 보이네요. 근데 파일의 데이타가 ‘)L(L’로 바뀌어 버
렸어요!!!
화면에 표시가 되면서 실제 데이타가 바뀌는 것은 아닙니다. 그냥 화면에만 그렇게
보일 뿐이죠. 제대로 화면에 표시가 안 되는 것을 고치다 보면 실제 제대로된 데이
타가 손상되는 경우도 많습니다.
실습링크
Back to Unicode Bidirectional Algorithm
Unicode에서는 RTL, LTR 문자들이 제대로 보이게 하기 위해서 눈에 안 보이는 컨
트롤 문자들을 보조로 사용합니다. 문자표 링크
기존의 LRE나 RLE로 방향성을 가진 문자들은 원래 방향성을 가진 문자처럼 외부
에도 영향을 줬습니다. 그러나 Isolate는 외부에는 영향을 주지 않습니다.
Implicit Directional Formatting Characters
(일반 LRT, RTL, Arabic Number처럼 동작)
LRM, RLM, ALM
Explicit Directional Embedding and
Override Formatting Characters
(Embedding: 중립을 특정 방향, Override:
무조건 특정 방향)
LRE, RLE, LRO, RLO, PDF
Explicit Directional Isolate Formatting
Characters
(중립을 특정 방향으로. 단, 외부 영향 없이)
LRI, RLI, FSI, PDI
4 Main Phases of UBA
1. 문단으로 분리하기.
UBA의 처리 단위는 문단입니다.
2. 초기화.
각 문자에 Bidi-Class 속성을 할당합니다.
3. embedding 단계 풀이
embedding level과 bidirectional character type의 목록에 규칙을 적용합니다.
4. Reordering!!!
Isolating Run
Isolation된 부분은 외부에 영향을 주지 못 합니다.
Paired Brackets
Isolated Run을 구한 후에 짝이 맞는 괄호를 찾습니다.
Text
1 2 3 4 5 6 7 8
Pairings
a ) b ( c None
a ( b ] c None
a ( b ) c 2-4
a ( b [ c ) d ] 2-6
a ( b ] c ) d 2-6
a ( b ) c ) d 2-4
a ( b ( c ) d 4-6
a ( b ( c ) d ) 2-8, 4-6
a ( b { c } d ) 2-8, 4-6
N0 rule
N0 규칙은 Unicode 6.3에서 새로 추가되었다.
Process bracket pairs in an isolating run sequence sequentially in the logical order
of the text positions of the opening paired brackets using the logic given below.
Within this scope, bidirectional types EN and AN re treated as R
1. 괄호쌍을 찾아서 아래 규칙을 적용한다.
a. 괄호쌍 안의 글자들의 bidirectional type을 찾는다.
b. strong type이 있는 경우, 양쪽 괄호를 발견한 strong type과 같은 방향으로 맞춘다.
c. 문단의 embedding direction 과 반대되는 strong type이 괄호 안에 없는 경우에는 괄호 앞에서
첫번째 나오는 strong type을 찾는다.
i. 첫번째 strong type이 문단의 embedding direction과 반대이면 그 방향에 괄호를 맞춘다.
ii. 그 외의 경우에는 문단의 embedding direction에 괄호의 방향을 맞춘다.
Summary
Unicode 6.3 has ‘directional isolation’ and ‘paired brackets’ update
Unicode 8.0 has new minor changes to handle identified edge cases
UBA solve most bidirectional problem, not every problem.
Reference
1. http://www.unicode.org/reports/tr9/index.html
2. http://www.unicode.org/review/pri231/
3. http://unicode.org/cldr/utility/bidi.jsp?a=a%28b%29&p=RTL
4. https://en.wikipedia.org/wiki/Bi-directional_text
5. https://developer.mozilla.org/ko/docs/Web/CSS/unicode-bidi
6. http://www.w3.org/International/articles/inline-bidi-markup/uba-basics
Implementation
● Unicode (C/Java): http://www.unicode.org/reports/tr41/tr41-17.html#Code9
● ICU: http://userguide.icu-project.org/transforms/bidi

More Related Content

Viewers also liked

NUS Scotland Strategic Objectives
NUS Scotland Strategic ObjectivesNUS Scotland Strategic Objectives
NUS Scotland Strategic Objectivesliam396
 
Eco quiz present tense review
Eco quiz present tense reviewEco quiz present tense review
Eco quiz present tense reviewduvan92
 
Nobel Laureates and their Ultimate Conclusion.
Nobel Laureates and their Ultimate Conclusion.Nobel Laureates and their Ultimate Conclusion.
Nobel Laureates and their Ultimate Conclusion.Steven Camilleri
 
What will happen next
What will  happen nextWhat will  happen next
What will happen nextduvan92
 
Nobel Laureates Quotes (I Believe)
Nobel Laureates Quotes (I Believe)Nobel Laureates Quotes (I Believe)
Nobel Laureates Quotes (I Believe)Steven Camilleri
 
The Real Land of the Giants
The Real Land of the GiantsThe Real Land of the Giants
The Real Land of the GiantsSteven Camilleri
 
Phenomenal Wonders of the Natural World
Phenomenal Wonders of the Natural WorldPhenomenal Wonders of the Natural World
Phenomenal Wonders of the Natural WorldSteven Camilleri
 
Internet based project works
Internet  based project works Internet  based project works
Internet based project works duvan92
 
Telecom BiWeekly Highlight2008 08
Telecom BiWeekly Highlight2008 08Telecom BiWeekly Highlight2008 08
Telecom BiWeekly Highlight2008 08yuanxiaole
 
Humble introduction to category theory in haskell
Humble introduction to category theory in haskellHumble introduction to category theory in haskell
Humble introduction to category theory in haskellJongsoo Lee
 
Adapting materials
Adapting materialsAdapting materials
Adapting materialsduvan92
 

Viewers also liked (13)

NUS Scotland Strategic Objectives
NUS Scotland Strategic ObjectivesNUS Scotland Strategic Objectives
NUS Scotland Strategic Objectives
 
Eco quiz present tense review
Eco quiz present tense reviewEco quiz present tense review
Eco quiz present tense review
 
Texas Giant Human Skull
Texas Giant Human SkullTexas Giant Human Skull
Texas Giant Human Skull
 
Nobel Laureates and their Ultimate Conclusion.
Nobel Laureates and their Ultimate Conclusion.Nobel Laureates and their Ultimate Conclusion.
Nobel Laureates and their Ultimate Conclusion.
 
What will happen next
What will  happen nextWhat will  happen next
What will happen next
 
Nobel Laureates Quotes (I Believe)
Nobel Laureates Quotes (I Believe)Nobel Laureates Quotes (I Believe)
Nobel Laureates Quotes (I Believe)
 
The Real Land of the Giants
The Real Land of the GiantsThe Real Land of the Giants
The Real Land of the Giants
 
The King James Holy Bible
The King James Holy BibleThe King James Holy Bible
The King James Holy Bible
 
Phenomenal Wonders of the Natural World
Phenomenal Wonders of the Natural WorldPhenomenal Wonders of the Natural World
Phenomenal Wonders of the Natural World
 
Internet based project works
Internet  based project works Internet  based project works
Internet based project works
 
Telecom BiWeekly Highlight2008 08
Telecom BiWeekly Highlight2008 08Telecom BiWeekly Highlight2008 08
Telecom BiWeekly Highlight2008 08
 
Humble introduction to category theory in haskell
Humble introduction to category theory in haskellHumble introduction to category theory in haskell
Humble introduction to category theory in haskell
 
Adapting materials
Adapting materialsAdapting materials
Adapting materials
 

Recently uploaded

MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionKim Daeun
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Kim Daeun
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Wonjun Hwang
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)Tae Young Lee
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Wonjun Hwang
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스
 

Recently uploaded (6)

MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 

Unicode bidirectional algorithm

  • 1. Changes of Unicode Bidirectional Algorithm at Unicode 6.3 Unicode Standard Annex #9 leejongsoo@gmail.com
  • 2. Introduction 세상에는 다양한 ‘writing system’이 있습니다. 왼쪽에서 오른쪽으로 쓰기도 하고 고하 도기쓰 로으쪽왼 서에쪽른오 이 중 가장 많이 쓰이는 것은 왼쪽에서 오른쪽으로 쓰기입니다. 한글도 주로 그렇게 씁니다. 그러나 우리랑 다르게 사용하는 소수의 문화도 존중해야 합니다. 위 에 서 아 래 로 쓰 기 도 합 니 다
  • 3. Not Right-to-Left, Bidirectional! 아래 언어들은 오른쪽에서 왼쪽으로 씁니다. 영어로는 ‘Right-to-Left’라고 해요. - Arabic Script: Arabic, Persian, Urdu, … - Hebrew Script: Hebrew, Yiddish - Syriac Script: Syriac - 그 외 여러가지 언어 근데 오른쪽에서 왼쪽 방향이 아니라 양방향일까요? 컴퓨터 세상에서는 영어와 같은 ‘Left-to-Right’ Script나 0,1,2,3과 같은 숫자와 함께 사용되는 것이 대부분이라서 ‘Bidirectional’, ‘양방향' 을 처리해줘야 합니다.
  • 4. Unicode Annex #9 - UBA Unicode 에서 요런 저런 부분을 보완하는 표준들이 있는데, Annex라고 부릅니다. 이 중에서 #9가 ‘Bidirectional Algorithm’에 대한 내용입니다. UBA는 1998년 10월 30일에 최초로 만들어졌습니다. 그리고 2013년 9월 24일 Unicode 6.3에서 2 가지 중요한 개선이 이루어졌습니다. 1. Directional Isolation 2. Paired Brackes
  • 5. Too many error!!! Why? Unicode의 모든 문자들은 direction 정보를 가지고 있습니다. ‘a’는 L(eft-to-Right) 문자, ‘‫ل‬’는 R(ight-to-Left) 문자 그리고 공백 기호들은 ‘Neutral’ 문자. 그리고 0,1 같은 숫자들은 방향성은 있지만 강하지는 않아서 ‘Weak’ 문자입니다. 모든 문제는 항상 불확실성에서 발생합니다. 즉, Neutral이나 Weak 같은 문자들이 문제를 만듭니다.
  • 6. Error example RTL 문단 중간에 LTR 이 있다고 하면… “RRRRR RRRR L(L) RRR RRRRRR” 기존의 알고리즘에서는 Weak 문자들은 자기 주변을 둘러싼 글자의 방향성을 따릅 니다. 따라서 ‘(‘는 L로 간주합니다. L(L) => LLL? 문제는 ‘)’ 입니다. 해당 문단의 방향은 RTL이고 앞뒤로 LTR이 있는 것도 아니니 R 이 됩니다. L(L) => LLLR
  • 7. Error Case before Unicode 6.3
  • 8. Programmer should be lazy. 사실 무식하지 않아도 평범하고 부지런한 사람이라면 문제를 해결하려 합니다. 부지런씨: ‘)L(L’ 로 잘못 나오는 것은 ‘L(L)’ 로 고쳐야죠. 그랬더니 화면에 똑바로 ‘L(L)’로 보이네요. 근데 파일의 데이타가 ‘)L(L’로 바뀌어 버 렸어요!!! 화면에 표시가 되면서 실제 데이타가 바뀌는 것은 아닙니다. 그냥 화면에만 그렇게 보일 뿐이죠. 제대로 화면에 표시가 안 되는 것을 고치다 보면 실제 제대로된 데이 타가 손상되는 경우도 많습니다. 실습링크
  • 9. Back to Unicode Bidirectional Algorithm Unicode에서는 RTL, LTR 문자들이 제대로 보이게 하기 위해서 눈에 안 보이는 컨 트롤 문자들을 보조로 사용합니다. 문자표 링크 기존의 LRE나 RLE로 방향성을 가진 문자들은 원래 방향성을 가진 문자처럼 외부 에도 영향을 줬습니다. 그러나 Isolate는 외부에는 영향을 주지 않습니다. Implicit Directional Formatting Characters (일반 LRT, RTL, Arabic Number처럼 동작) LRM, RLM, ALM Explicit Directional Embedding and Override Formatting Characters (Embedding: 중립을 특정 방향, Override: 무조건 특정 방향) LRE, RLE, LRO, RLO, PDF Explicit Directional Isolate Formatting Characters (중립을 특정 방향으로. 단, 외부 영향 없이) LRI, RLI, FSI, PDI
  • 10. 4 Main Phases of UBA 1. 문단으로 분리하기. UBA의 처리 단위는 문단입니다. 2. 초기화. 각 문자에 Bidi-Class 속성을 할당합니다. 3. embedding 단계 풀이 embedding level과 bidirectional character type의 목록에 규칙을 적용합니다. 4. Reordering!!!
  • 11. Isolating Run Isolation된 부분은 외부에 영향을 주지 못 합니다.
  • 12. Paired Brackets Isolated Run을 구한 후에 짝이 맞는 괄호를 찾습니다. Text 1 2 3 4 5 6 7 8 Pairings a ) b ( c None a ( b ] c None a ( b ) c 2-4 a ( b [ c ) d ] 2-6 a ( b ] c ) d 2-6 a ( b ) c ) d 2-4 a ( b ( c ) d 4-6 a ( b ( c ) d ) 2-8, 4-6 a ( b { c } d ) 2-8, 4-6
  • 13. N0 rule N0 규칙은 Unicode 6.3에서 새로 추가되었다. Process bracket pairs in an isolating run sequence sequentially in the logical order of the text positions of the opening paired brackets using the logic given below. Within this scope, bidirectional types EN and AN re treated as R 1. 괄호쌍을 찾아서 아래 규칙을 적용한다. a. 괄호쌍 안의 글자들의 bidirectional type을 찾는다. b. strong type이 있는 경우, 양쪽 괄호를 발견한 strong type과 같은 방향으로 맞춘다. c. 문단의 embedding direction 과 반대되는 strong type이 괄호 안에 없는 경우에는 괄호 앞에서 첫번째 나오는 strong type을 찾는다. i. 첫번째 strong type이 문단의 embedding direction과 반대이면 그 방향에 괄호를 맞춘다. ii. 그 외의 경우에는 문단의 embedding direction에 괄호의 방향을 맞춘다.
  • 14. Summary Unicode 6.3 has ‘directional isolation’ and ‘paired brackets’ update Unicode 8.0 has new minor changes to handle identified edge cases UBA solve most bidirectional problem, not every problem.
  • 15. Reference 1. http://www.unicode.org/reports/tr9/index.html 2. http://www.unicode.org/review/pri231/ 3. http://unicode.org/cldr/utility/bidi.jsp?a=a%28b%29&p=RTL 4. https://en.wikipedia.org/wiki/Bi-directional_text 5. https://developer.mozilla.org/ko/docs/Web/CSS/unicode-bidi 6. http://www.w3.org/International/articles/inline-bidi-markup/uba-basics Implementation ● Unicode (C/Java): http://www.unicode.org/reports/tr41/tr41-17.html#Code9 ● ICU: http://userguide.icu-project.org/transforms/bidi