Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bidirectional text
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Text that contains both LTR and RTL text}} {{More citations needed|date=July 2015}} {{hatnote|Some web browsers may display the Hebrew text in this article in the reverse direction.}} A '''bidirectional text''' contains two [[text direction]]alities, [[right-to-left]] (RTL) and [[left-to-right]] (LTR). It generally involves text containing different types of [[alphabet]]s, but may also refer to [[boustrophedon]], which is changing text direction in each row. An example is the RTL Hebrew name Sarah: {{Lang|he|שרה}}, spelled sin (ש) on the right, resh (ר) in the middle, and heh (ה) on the left. Many computer programs failed to display this correctly, because they were designed to display text in one direction only. Some so-called [[right-to-left script]]s such as the [[Persian alphabet|Persian script]] and Arabic are mostly, but not exclusively, right-to-left—mathematical expressions, numeric dates and numbers bearing units are embedded from left to right. That also happens if text from a left-to-right language such as English is embedded in them; or vice versa, if Arabic is embedded in a left-to-right script such as English. == Bidirectional script support == {{anchor|Unicode support}}<!-- used externally --> Bidirectional script support is the capability of a [[computer]] system to correctly display bidirectional text. The term is often shortened to "'''BiDi'''" or "'''bidi'''". Early computer installations were designed only to support a single [[writing system]], typically for left-to-right scripts based on the [[Latin alphabet]] only. Adding new [[character set]]s and [[character encoding]]s enabled a number of other left-to-right scripts to be supported, but did not easily support right-to-left scripts such as [[Arabic script|Arabic]] or [[Hebrew alphabet|Hebrew]], and mixing the two was not practical. Right-to-left scripts were introduced through encodings like [[ISO/IEC 8859-6]] and [[ISO/IEC 8859-8]], storing the letters (usually) in writing and reading order. It is possible to simply flip the left-to-right display order to a right-to-left display order, but doing this sacrifices the ability to correctly display left-to-right scripts. With bidirectional script support, it is possible to mix characters from different scripts on the same page, regardless of writing direction. In particular, the [[Unicode]] standard provides foundations for complete BiDi support, with detailed rules as to how mixtures of left-to-right and right-to-left scripts are to be encoded and displayed. == Unicode bidi support == {{see also|Right-to-left mark|Left-to-right mark|Arabic letter mark}} The Unicode standard calls for characters to be ordered 'logically', i.e. in the sequence they are intended to be interpreted, as opposed to 'visually', the sequence they appear. This distinction is relevant for bidi support because at any bidi transition, the visual presentation ceases to be the 'logical' one. Thus, in order to offer bidi support, Unicode prescribes an algorithm for how to convert the logical sequence of characters into the correct visual presentation. For this purpose, the Unicode encoding standard divides all its characters into one of four types: 'strong', 'weak', 'neutral', and 'explicit formatting'.<ref name="Bidi_UAX9">{{cite web|url=https://www.unicode.org/reports/tr9/#Resolving_Weak_Types |title=UAX #9: Unicode Bi-directional Algorithm |publisher=Unicode.org |date=2018-05-09 |access-date=2018-06-26}}</ref> === Strong characters === Strong characters are those with a definite direction. Examples of this type of character include most alphabetic characters, syllabic characters, Han ideographs, non-European or non-Arabic digits, and punctuation characters that are specific to only those scripts. === Weak characters === Weak characters are those with vague direction. Examples of this type of character include European digits,<!--Debian doesn't work this way: "حج6341" does not show the year as "1436"--> Eastern Arabic-Indic digits, arithmetic symbols, and currency symbols. === Neutral characters === Neutral characters have direction indeterminable without context. Examples include paragraph separators, tabs, and most other whitespace characters. Punctuation symbols that are common to many scripts, such as the colon, comma, full-stop, and the no-break-space also fall within this category. === Explicit formatting === Explicit formatting characters, also referred to as "directional formatting characters", are special Unicode sequences that direct the algorithm to modify its default behavior. These characters are subdivided into "marks", "embeddings", "isolates", and "overrides". Their effects continue until the occurrence of either a paragraph separator, or a "pop" character. ==== Marks ==== {{see also|Right-to-left mark|Left-to-right mark|Arabic letter mark}} If a "weak" character is followed by another "weak" character, the algorithm will look at the first neighbouring "strong" character. Sometimes this leads to unintentional display errors. These errors are corrected or prevented with "pseudo-strong" characters. Such [[Unicode control characters]] are called ''marks''. The mark ({{unichar|200E|Left-to-right mark|note=LRM}} or {{unichar|200F|Right-to-left mark|note=RLM}}) is to be inserted into a location to make an enclosed weak character inherit its writing direction. For example, to correctly display the {{unichar|2122|trade mark sign}} for an English name brand (LTR) in an Arabic (RTL) passage, an LRM mark is inserted after the trademark symbol if the symbol is not followed by LTR text (e.g. "{{lang|ar|قرأ Wikipedia™‎ طوال اليوم.|rtl=yes}}"). If the LRM mark is not added, the weak character ™ will be neighbored by a strong LTR character and a strong RTL character. Hence, in an RTL context, it will be considered to be RTL, and displayed in an incorrect order (e.g. "{{lang|ar|قرأ Wikipedia™ طوال اليوم.|rtl=yes}}"). ==== Embeddings ==== The "embedding" directional formatting characters are the classical Unicode method of explicit formatting, and as of Unicode 6.3, are being discouraged in favor of "isolates". An "embedding" signals that a piece of text is to be treated as directionally distinct. The text within the scope of the embedding formatting characters is not independent of the surrounding text. Also, characters within an embedding can affect the ordering of characters outside. Unicode 6.3 recognized that directional embeddings usually have too strong an effect on their surroundings and are thus unnecessarily difficult to use. ==== Isolates ==== The "isolate" directional formatting characters signal that a piece of text is to be treated as directionally isolated from its surroundings. As of Unicode 6.3, these are the formatting characters that are being encouraged in new documents – once target platforms are known to support them. These formatting characters were introduced after it became apparent that directional embeddings usually have too strong an effect on their surroundings and are thus unnecessarily difficult to use. Unlike the legacy 'embedding' directional formatting characters, 'isolate' characters have no effect on the ordering of the text outside their scope. Isolates can be nested, and may be placed within embeddings and overrides. ==== Overrides ==== The "override" directional formatting characters allow for special cases, such as for part numbers (e.g. to force a part number made of mixed English, digits and Hebrew letters to be written from right to left), and are recommended to be avoided wherever possible. As is true of the other directional formatting characters, "overrides" can be nested one inside another, and in embeddings and isolates. ===== Using Unicode to override ===== {{Anchor|Using unicode to override}}Using {{Unichar|202D}} will switch the text direction from left-to-right to right-to-left. Similarly, using {{Unichar|202e}} will switch the text direction from right-to-left to left-to-right. Refer to the [https://www.unicode.org/reports/tr9/ Unicode Bidirectional Algorithm]. ==== Pops ==== The "pop" directional formatting character, encoded at {{Unichar|202C}}, terminates the scope of the most recent "embedding", "override", or "isolate". === Runs === In the algorithm, each sequence of concatenated strong characters is called a "run". A "weak" character that is located between two "strong" characters with the same orientation will inherit their orientation. A "weak" character that is located between two "strong" characters with a different writing direction will inherit the main context's writing direction (in an LTR document the character will become LTR, in an RTL document, it will become RTL). === Table of possible BiDi character types === {{Bidi Class (Unicode)|state=expanded}} === Security === Unicode bidirectional characters are used in the [[Trojan Source]] vulnerability.<ref>{{cite web |title=Trojan Source Attacks |url=https://trojansource.codes/ |website=trojansource.codes |access-date=17 January 2022}}</ref> [[Visual Studio Code]] highlights BiDi control characters since version 1.62 released in October 2021.<ref>{{cite web |title=Visual Studio Code October 2021 |url=https://code.visualstudio.com/updates/v1_62#_unicode-directional-formatting-characters |website=code.visualstudio.com |access-date=11 November 2021 |language=en}}</ref> [[Visual Studio]] highlights BiDi control characters since version 17.0.3 released on December 14, 2021.<ref>{{cite web |title=Visual Studio 2022 version 17.0 Release Notes |url=https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes#1703--visual-studio-2022-version-1703 |website=docs.microsoft.com |access-date=17 January 2022 |language=en-us}}</ref> == Scripts using bidirectional text == === Egyptian hieroglyphs === [[Egyptian language|Egyptian]] [[Egyptian hieroglyph|hieroglyphs]] were written bidirectionally, where the signs that had a distinct "head" or "tail" faced the beginning of the line. === Chinese characters and other CJK scripts === [[Chinese characters]] can be written in either direction as well as vertically (top to bottom then right to left), especially in signs (such as plaques), but the orientation of the individual characters does not change. This can often be seen on tour buses in China, where the company name customarily runs from the front of the vehicle to its rear — that is, from right to left on the right side of the bus, and from left to right on the left side of the bus. English texts on the right side of the vehicle are also quite commonly written in reverse order. (See pictures of tour bus and post vehicle below.) Likewise, other [[CJK characters|CJK]] scripts made up of the same square characters, such as the [[Japanese writing system]] and [[Korean writing system]], can also be written in any direction, although horizontally left-to-right, top-to-bottom and vertically top-to-bottom right-to-left are the two most common forms. <gallery mode=packed> Image:Yangzhou-tour-bus--right-side-3182.jpg|The right side (text runs from right to left, including the English text) Image:Yangzhou-tour-bus--leftt-side-3184.jpg|The left side (text runs from left to right) Image:Hainan Airlines - Boeing 737-86N.jpg| On the right side of this [[Hainan Airlines]] aircraft, the text runs from right to left ({{lang|zh|空航南海}}). Image:Hainan Airlines.JPG|The left side of this Hainan Airlines aircraft, however, shows the text running from left to right ({{lang|zh|海南航空}}). File:VM 5485 China Post Office car at Zhengzhou Train Station.jpg|A photo that shows text on both sides of a China Post vehicle. On the right door, {{Smallcaps|china post}} appears as {{Smallcaps|tsop anihc}}. </gallery> === Boustrophedon === [[Boustrophedon]] is a writing style found in ancient [[Greek language|Greek]] inscriptions, in [[Sabaic|Old Sabaic]] (an [[Old South Arabian]] language) and in [[Hungarian runes]]. This method of writing alternates direction, and usually reverses the individual characters, on each successive line. ===Moon type=== [[Moon type]] is an embossed adaptation of the Latin alphabet invented as a [[tactile alphabet]] for the blind. Initially the text changed direction (but not character orientation) at the end of the lines. Special embossed lines connected the end of a line and the beginning of the next.<ref name="Ramseyer">''[http://www.d.umn.edu/lib/bible/displays/rare/moon.htm Moon Type for the Blind]'', [[Ramseyer Bible Collection]], [[Kathryn A. Martin Library]], [[University of Minnesota Duluth]].</ref> Around 1990, it changed to a [[left-to-right]] orientation. == See also == * [[Internationalization and localization]] * [[Horizontal and vertical writing in East Asian scripts]] * {{section link|Writing system|Directionality and orientation}} * [[Cyrillic numerals]] * [[Right-to-left mark]] * [[Transformation of text]] * [[Boustrophedon]] == References == {{reflist}} == External links == * [https://www.unicode.org/reports/tr9/ Unicode Standards Annex #9] The Bidirectional Algorithm * [http://www.w3.org/TR/i18n-html-tech-bidi/ W3C guidelines on authoring techniques for bi-directional text] - includes examples and good explanations * [http://www.icu-project.org/ ICU] [[International Components for Unicode]] contains an implementation of the bi-directional algorithm — along with other internationalization services {{Unicode navigation}} [[Category:Character encoding]] [[Category:Unicode algorithms]] [[Category:Internationalization and localization]] [[Category:Writing direction]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Anchor
(
edit
)
Template:Bidi Class (Unicode)
(
edit
)
Template:Cite web
(
edit
)
Template:Hatnote
(
edit
)
Template:Lang
(
edit
)
Template:More citations needed
(
edit
)
Template:Reflist
(
edit
)
Template:Section link
(
edit
)
Template:See also
(
edit
)
Template:Short description
(
edit
)
Template:Smallcaps
(
edit
)
Template:Unichar
(
edit
)
Template:Unicode navigation
(
edit
)