143

Me and a friend were joking about aleph's. Upon trying to type א0 (switch those 2 chars), they switched themselves! Any sequence of symbols does not stop this effect. Why is this!??

Try to type these with the 0 and א reversed (c&p for א):

א0

א - 0

א \\\ 0

א -./ 0

Words however separate them

א foobar 0

I'm on arch linux and have not tested this on any other OS yet

EDIT: Number does not have to be zero. It works with numbers, but not letters.

8 Answers8

197

Aleph (U+05D0) is a Hebrew letter, and Hebrew is written right-to-left, so Unicode assigns it the "Right-to-Left" bidirectional class. (See Unicode TR9: Bidirectional Algorithm for more details.)

Latin letters are of course "Left-to-Right". However, zero (U+0030) is in the "European Number" bidirectional class, which is a weak class – while LtR by default, it can switch to RtL if there's a "strong" Right-to-Left character before it. (See Bidirectional Character Types and Resolving Weak Types in TR9.)

As a result, the directions of before and after are swapped for the entire word – if you put the zero 'before', it will show up to the right; if you write the zero 'after' aleph, it will show up on the left.

grawity
  • 501,077
110

'א', 'HEBREW LETTER ALEF' (U+05D0) has the BIDI (bi-directional) class "Right-to-Left [R]", because Hebrew is traditionally written right-to-left. Digits, on the other hand, have no specific directionality assigned to them, and so the whole chunk of aleph and zero is interpreted as being right-to-left. In this case, the following character may not necessarily be located on the right of the preceding character, as Unicode's rather complex bi-directional rules dictate.

You have several options to work around this issue.

  1. You can use 'ℵ', 'ALEF SYMBOL' (U+2135). It's a symbol and has the left-to-right property: ℵ0.

  2. Instead of the usual digit 0, you can use a zero-like character with left-to-right directionality, such as '〇', 'IDEOGRAPHIC NUMBER ZERO' (U+3007).

  3. The cleanest way is to use the 'LEFT-TO-RIGHT MARK' (U+200E) character (Wikipedia) after the aleph: "א‎0". This is an invisible zero-width character that is defined to have left-to-right directionality. Thus, it has the same effect on the bidirectional text layout algorithm as inserting, say, a left-to-right Latin letter after the א, except that no visible letter will appear there.

IS4
  • 1,490
22

Perhaps, a better way to achieve this would be to:

echo -e "\u200F0א"

And the mandatory xkcd reference https://xkcd.com/1137/

‮LTR

Arjan
  • 31,511
wvxvw
  • 883
14

It's perfectly possible to have a zero in front as shown in the following example which was made in Notepad++.

Alef with 0

What you're seeing and also becomes apparent if you try to mark the character in your question, is that Hebrew is written right to left and (as the 0 is directly connected) the text is handled in a right to left (instead of left to right) manner.

See the second example for the trouble Firefox (on my end) has with a clear selection.

Firefox selecting a right to left text

Seth
  • 9,393
13

Hebrew is written right to left - this makes the aleph character carry the information, that the next character should be printed left of it.

If you hex-check your document (or move the cursor through your text with the arrow keys in a suitable editor), you will notice, that you get to the alpeh first, then to the digit.

I.e.: The assumption "next character == character to the right" does not hold.

Eugen Rieck
  • 20,637
3

א0 0א 0-א א-0

The issue is where you do this, and the implementation. To get Hebrew-number behavior all the characters must be in right-to-left directionality. In HTML/CSS that is:

<p style="direction:rtl"> א0 0א 0-א א-0 </p>

In the Operating System, Hebrew and bi-directionality must be enabled.

The workarounds by suggesting the use of other characters as substitutes, defeats the purpose of Unicode. The aleph as a mathematical operator may look the same in some character sets, but is an entirely different character than the Hebrew aleph, both in context and how it will be parsed. For example, a Hebrew-native speaker/computer will not process it correctly if used in conjunction with a Hebrew word. Numbers and non-alpha characters are a problem when they are not themselves given the same directional encoding as the alpha characters. Thus, ironically, numbers themselves while seemingly should be independent of a character-set/directionality, take on whatever unicode directionality of the preceding letter. Thus in a Hebrew document - the numbers become 'Hebraicised' i.e. directionally like Hebrew. Whereas an English-Latin document, the Hebrew letters can be mixed up and messed up because of the lack of directionality attributed to the paragraph.

Danny F
  • 160
1

It's possible:

‭א0

‭א - 0

‭א \\ 0

‭א -./ 0

‭א foobar 0

(This answer didn't answer "why is this", as it is already answered by others. But it does answer the question in the title, "impossible to...?")

user23013
  • 254
0

It is actually more obvious if you will copy א in the editor that supports it correctly! Like (yes, hillarious) Chrome url omnibox. The WHOLE style of it will change. Also as you may be interesting, just like with Ohm vs Omega (that is commonly mistaken in TrueType and OpenType fonts files, .Omega glyph is not U+2126 (Ohm), it is U+03A9 (Omega)) for math you should use ℵ, not א.