Adam Matan
Adam Matan

Reputation: 136421

nodejs: Print a Hebrew RTL string to the shell

The following JS Object contains Hebrew Strings:

  { stationId: 359,
    location: { lat: 32.0732, lon: 34.7859, address: 'קפלן פינת ארניה' },
    bikes: { availableBikes: 12, availableParkingSlots: 16 } },
  { stationId: 116,
    location: { lat: 32.1022, lon: 34.7854, address: 'שי עגנון 59' },
    bikes: { availableBikes: 5, availableParkingSlots: 13 } },
  { stationId: 314,
    location: { lat: 32.0917, lon: 34.7826, address: 'נורדאו 101בשדרה' },
    bikes: { availableBikes: 9, availableParkingSlots: 10 } },

However, when the object is printed to the shell (iTerm2 with zsh), the Hebrew strings are shown as LTR (first letter is on the left-hand side of the string, instead of the right-hand side as it should).

Object in shell

Note that this problem can not be solved by simply reversing the string, because it would also reverse numbers and English words which should appear LTR.

How can I correctly print the Hebrew RTL strings to the shell in nodejs?

Upvotes: 1

Views: 1232

Answers (1)

Nir Levy
Nir Levy

Reputation: 4740

The issue is with iTerm2, not node.js. iTerm2 does not properly supports RTL. See https://gitlab.com/gnachman/iterm2/issues/1611.

Using standard Mac OS X Terminal should display the text properly.

Upvotes: 3

Related Questions