1

I cannot get Mac Terminal to display U+200C, aka zero-width non-joiner, correctly. Instead, it simply types <200c>.

Unicode settings for the profile I use have been set to UTF-8 as described on this Apple Support page. I am also using a font which has a glyph for this character, as I can test it in Font Book.

Any ideas on how to get Terminal to display this character properly? In case you want to try it, use the below text and see if it appears in your terminal as in the webpage.

می‌روم

(Persian word meaning I'm going).

P.S. Let me know if you happen to know another terminal on any other platform which might correctly display this character.

11
  • If I assign that string to a variable and then echo the variable, I get what looks like the right output. Is that what you're doing?
    – Linc Davis
    Commented Oct 18 at 19:55
  • Strangely enough, I get the right output. Commented Oct 18 at 20:25
  • To be more specific, I see this at first: str='می<200c>روم', but when I run echo $str, it correctly displays: می‌روم. How can I get it to display correctly in the first place? Commented Oct 18 at 20:34
  • Like you both, (UTF-8 enabled) directly pasting the characters I get the wrong output, but assigning to a variable, it's shown correctly as per OP's example above when echoed. Interestingly I also tried using iTerm and while a straightforward paste also shows `<200c>, the character order looks different. Also assigning to a variable in iTerm 'works' but the 'correct' output isn't in the correct order again. OP, might you experiment with iTerm as well and see if that offers a new perspective on what may be happening? Commented Oct 18 at 20:37
  • 1
    Maybe you would find something here: github.com/vimpersian/vimpersian.github.io
    – Linc Davis
    Commented Oct 18 at 21:55

1 Answer 1

2

This is the line editor in whatever shell you're using mangling the text.

Here are a couple of examples.

In ksh (my default shell):

$ TEXT="می^⁌روم"
$ echo $TEXT
می‌روم
$

Notice, no garbage.

Note that bash doesn't have the problem either.

$ bash
$ TEXT="می‌روم"
$ echo $TEXT
می‌روم
$ 

Now, in zsh:

$ zsh
% TEXT="می<200c>روم"
% echo $TEXT
می‌روم
% 

Note the garbage for the first character. But the string is in the variable, so Terminal outputs it correctly.

6
  • 1
    I just noticed that ksh didn't deal with it correctly either when I pasted it, but it echoed it correctly. Guess that wasn't the best example although it doesn't print an escape. ^_^ Commented Oct 19 at 16:44
  • 1
    Can concur that bash works correctly when pasted, and works as expected (L to R) when backspace is used. Here's the issue reported on the zsh mailing list, but it didn't get much traction or a solution. zsh.org/mla/workers/2023/msg00789.html Commented Oct 19 at 16:48
  • Thanks @MarcWilson. I now realize the problem had to do with the shell. But my original problem – Vim not displaying U+200C correctly – still remains, even if I open Vim after invoking bash. Do you think I should open a new question on Vim Stack Exchange or Stack Overflow? Commented Oct 20 at 2:49
  • It turns out it has already been asked and answered here. Commented Oct 20 at 3:04
  • 2
    If you've solved the problem, please post the solution as an answer here and accept it. By the way, vim has its own line editor and doesn't use the one provided by the shell.
    – Linc Davis
    Commented Oct 20 at 3:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .