คุณสมบัติ

หมวดหมู่สองทิศทาง

คุณสมบัติที่กำหนดว่าอักขระมีพฤติกรรมอย่างไรในข้อความสองทิศทาง (LTR, RTL, อ่อน, เป็นกลาง) ใช้โดยอัลกอริธึม Bidirectional ของ Unicode เพื่อกำหนดลำดับการแสดงผล

· Updated

What Is the Bidirectional Category?

The Bidi Class (formally Bidi_Class, also called bidirectional category) is a Unicode property that controls how characters are positioned in a line of mixed left-to-right (LTR) and right-to-left (RTL) text. It is the primary input to the Unicode Bidirectional Algorithm (UBA, described in Unicode Standard Annex #9), which determines the visual display order of characters in a paragraph.

Every code point is assigned one of 23 Bidi Class values. The algorithm uses these values—along with explicit directional override characters—to resolve the correct rendering order for Arabic mixed with English, Hebrew mixed with numbers, or any other bidirectional combination.

The Major Bidi Class Values

Code Name Typical Characters
L Left-to-Right Latin letters, digits in LTR context
R Right-to-Left Hebrew letters
AL Arabic Letter Arabic and Thaana letters
EN European Number 0–9
AN Arabic Number Arabic-Indic digits ٠–٩
ES European Separator + −
ET European Terminator $ % °
ON Other Neutral most punctuation
BN Boundary Neutral Format chars, ZWJ
NSM Non-Spacing Mark combining marks (inherit from base)
WS Whitespace space, tab
B Paragraph Separator U+2029
S Segment Separator tab in certain contexts
LRE/RLE/LRO/RLO Explicit Embedding directional embedding characters
LRM/RLM Mark U+200E LEFT-TO-RIGHT MARK, U+200F
LRI/RLI/FSI/PDI Isolate Unicode 6.3+ directional isolates
import unicodedata

chars = [("A", "Latin"), ("ب", "Arabic"), ("5", "Digit"),
         ("\u200F", "RLM"), ("\u200E", "LRM")]

for char, label in chars:
    bc = unicodedata.bidirectional(char)
    print(f"  {label:12} U+{ord(char):04X}  Bidi={bc}")

# Latin        U+0041  Bidi=L
# Arabic       U+0628  Bidi=AL
# Digit        U+0035  Bidi=EN
# RLM          U+200F  Bidi=R
# LRM          U+200E  Bidi=L

Why It Matters in Practice

Without correct bidi handling, a string like "Hello مرحبا World" will display with the Arabic word in the wrong position or with punctuation displaced. HTML provides dir attributes and the Unicode characters U+200F (RLM), U+200E (LRM), and the bidi isolate characters (U+2066–U+2069) to guide the algorithm. Web developers working with RTL content must understand that the visual order of characters on screen differs from their logical (storage) order.

Quick Facts

Property Value
Unicode property name Bidi_Class
Short alias bc
Number of values 23
Python function unicodedata.bidirectional(char) → string code
Algorithm spec Unicode Standard Annex #9 (UAX #9)
Key characters U+200E LRM, U+200F RLM, U+2066–U+2069 isolates

คำศัพท์ที่เกี่ยวข้อง

เพิ่มเติมใน คุณสมบัติ

East Asian Width

Unicode property (UAX#11) classifying characters as Narrow, Wide, Fullwidth, Halfwidth, Ambiguous, or …

Joining Type

Unicode property controlling how Arabic and Syriac characters connect to adjacent characters. …

Script Extensions

Unicode property listing all scripts that use a character, broader than the …

กลุ่มกราฟีม

อักขระที่ผู้ใช้รับรู้ได้ — สิ่งที่รู้สึกเหมือนหน่วยเดียว อาจประกอบด้วยหลายจุดรหัส (ฐาน + เครื่องหมายรวม หรือลำดับ emoji ZWJ) 👩‍💻 = …

การแมปตัวพิมพ์

กฎสำหรับแปลงอักขระระหว่างตัวพิมพ์ใหญ่ ตัวพิมพ์เล็ก และตัวพิมพ์หัวเรื่อง อาจขึ้นอยู่กับ locale (ปัญหาตัว I ในภาษาตุรกี) และอาจเป็นแบบหนึ่ง-ต่อ-หลาย (ß → SS)

การแยกส่วน

การแมปอักขระเป็นส่วนประกอบย่อย การแยกส่วนแบบ canonical รักษาความหมาย (é → e + ́) ในขณะที่การแยกส่วนแบบ compatibility อาจเปลี่ยนความหมาย …

คลาสการรวม

ค่าตัวเลข (0–254) ที่ควบคุมลำดับของเครื่องหมายรวมระหว่างการแยกส่วนแบบ canonical กำหนดว่าเครื่องหมายรวมใดสามารถเรียงลำดับใหม่ได้

ความสมมูลความเข้ากันได้

ลำดับอักขระสองชุดที่มีเนื้อหาเชิงนามธรรมเดียวกันแต่อาจแตกต่างในรูปลักษณ์ กว้างกว่าความเท่าเทียมแบบ canonical ตัวอย่าง: fi ≈ fi, ² ≈ 2

ความสมมูลมาตรฐาน

ลำดับอักขระสองชุดที่มีความหมายเหมือนกันและควรถือว่าเท่าเทียมกัน ตัวอย่าง: é (U+00E9) ≡ e + ◌́ (U+0065 + U+0301)

คุณสมบัติการสะท้อน

อักขระที่รูปร่างควรสะท้อนในแนวนอนในบริบท RTL ตัวอย่าง: ( → ), [ → ], { → }, …