Romaji yen sign in Terminal in the UTF-8 encoding

Hello all,

I have a MacBook Pro with a Japanese keyboard running Mac OS X 10.6.2. In Romaji mode, the Japanese keyboard has a dedicated yen sign (¥) key, and Option-¥ produces a backslash (\). In Terminal, for some reason, the ¥ key produces \ without the Option modifier. (Option-¥ also produces \ in Terminal, which is normal behavior.)

A similar situation was discussed in an older topic, http://discussions.apple.com/thread.jspa?messageID=10665836 , where the problem was diagnosed as having the Shift JIS encoding enabled in Terminal. However, this doesn‘t reflect my situation, since the only encoding that is enabled in my Terminal is UTF-8 – and there‘s certainly a yen sign available in UTF-8.

I am able to type other UTF-8 characters in Terminal in Romaji mode; for example, I can type Option-e e to produce é, and entering the command *echo é | od -x* within Terminal shows that the correct UTF-8 byte sequence is generated for é. Since the command *echo -e '\0302\0245'* within Terminal will produce a yen sign there, the problem seems to be connected to the key mapping rather than to a stty interface problem.

Is there anyone running 10.6.2 with a Japanese keyboard who can type the ¥ key in Romaji mode in Terminal with the UTF-8 encoding enabled, and have a yen sign appear rather than a backslash?

(This topic was initially posted in the +Installation and Setup+ forum, and I‘ve taken the advice of a kind soul there to repost the topic in this forum.)

MacBookPro5,5, Mac OS X (10.6.2), Japanese keyboard

Posted on Mar 15, 2010 7:13 PM

Reply
20 replies

Mar 16, 2010 4:41 AM in response to Baumkartoffel

I don't have Japanese keyboard for Mac, but the yen-sign ¥ can be input by typing option-y in most of Apps such as TextEdit, Safari, iWork, etc. But in Terminal.app option-y inputs backslash \. I can't find any settings which disable this "translation".
There is a historical reason for this, and it causes no trouble for most of Terminal users in Japan (including me), because we barely need the yen-sign in Terminal. For what purpose do you need to input ¥ in Terminal?

If you really need to input yen-sign in Terminal, a workaround is:
goto Terminal -> Preferences -> Settings -> Keyboard,
select a key in the list (such as "forward delete"),
push the Edit button,
and enter ¥ to the text box.
Then you can input ¥ by hitting the "forward delete" key.

Mar 16, 2010 8:18 AM in response to Jun T.

Jun, thanks for your reply. I am aware of the historical substitution of ¥ for \ [and ‾ for ~] in the JIS X 0201 character set, and realize that it would explain this behavior in Terminal if I were using the Shift JIS encoding, since Shift JIS is a strict superset of JIS X 0201. However, I’m using the UTF-8 encoding in Terminal, not Shift JIS; since UTF-8 is a strict superset of ASCII rather than of JIS X 0201, I don’t know why the ¥ for \ substitution happens in Terminal for the UTF-8 encoding. (Note that the ‾ for ~ substitution does not happen under UTF-8 in Terminal; only the ¥ for \ substitution happens.)

Generally I don’t need to enter ¥ on the Terminal command-line; since I use the vim text editor within Terminal, I can readily generate ¥ in Terminal while inserting text by typing the three-byte sequence *Control-k Y e* in vim — and if needed, feed that text file to the shell. (Cut and paste of ¥ from just about any other program to Terminal would work too.) My point is that Terminal’s UTF-8 encoding has apparently retained this one anachronistic keyboard substitution; for the UTF-8 encoding, this behavior is a bug, not a feature.

Since Option-y (which also produces ¥ on a Japanese keyboard) has the same behavior under UTF-8 in Terminal, that behavior is equally buggy.

Mar 16, 2010 9:47 AM in response to Baumkartoffel

I don't know the exact reason why ¥ is forcefully converted to \ in Terminal (even in UTF-8 encoding), and anyway it would be better to add an option to turn off this conversion (or there may already be a hidden option which I can't find).

But the conversion may be helpful for many users, as expected from the following reasons:

I guess there is no key for backslash on the Japanese keyboard of MacBook Pro. If this is the case, then being able to input \ by just hitting the ¥-key (instead of typing option-¥) may be "useful" for may Terminal users (because \ is used much more frequently than ¥ in programs). Kotoeri has an option to swap ¥ and option-¥ keys (so hitting ¥-key inputs \ and option-¥ inputs ¥), but this setting is global (i.e., not restricted to Terminal.app), so making this as the default setting may confuse most of Japanese users (they don't use Terminal.app at all, but uses ¥ as the currency symbol in other apps). Even Terminal users would use ¥ more frequently than \ in apps other then Terminal, so don't want to modify the global setting.

Another reason may be that there are still many Japanese textbooks for programing which uses ¥ as the escape character (I guess you know why). For example the first C program looks like: printf("Hello World!¥n"); So many beginners would try to input ¥ as written in the textbook, without knowing the escape character in UTF-8 should be \, not ¥. Converting ¥ to \ may be helpful for these users (of course they would be surprised to see not ¥ but \ appears on the screen, but anyway the program would work).

You can send a bug report or feature request at:
http://www.apple.com/feedback/macosx.html

Mar 16, 2010 10:45 PM in response to Jun T.

Jun, my guess as to the reason for the conversion of ¥ to \ in Terminal is maintaining the historical link between ASCII and JIS X 0201 for the sake of programmers with Japanese keyboards (i.e. mainly Japanese programmers) — that programmers are likely users of Terminal, that most programming languages depend upon the ASCII range of characters, that ¥ in JIS X 0201 has the same value as \ in ASCII, and that those programming languages that use the backslash (C, C++, Perl, &c.) really need the byte at position 0x5C more than the varying position of the yen sign in different character sets.

Pressing Option-¥ on a Japanese keyboard generates a backslash, and that works perfectly well in Terminal (as well as elsewhere).

Thanks for the feedback link; I’ve sent along a bug report/feature request (my suggestion was for a “Replace ¥ with \” checkbox in Terminal’s preferences under Settings → Advanced → International, where someone could have the possibility of unchecking it to let ¥ or Option-y generate ¥ rather than \ in Terminal). With luck it will be acted upon by the Mac OS X team.

If anybody knows of any way to generate a yen sign in Terminal under the UTF-8 encoding by using either the ¥ key or Option-y, please leave a reply!

Mar 17, 2010 9:50 AM in response to Baumkartoffel

maintaining the historical link between ASCII and JIS X 0201

This is just my second reason. The more important is my first reason, I think. If I need to type option-¥ every time I input backslash, then the terminal is virtually useless. Unless Apple add separate keys for ¥ and \ in Japanese keyboard, I guess almost all users would prefer current behavior.

Mar 17, 2010 3:36 PM in response to Jun T.

Jun, defining Terminal as “virtually useless” if one needed to press Option-¥ for a backslash on a Japanese keyboard is simply an exaggeration. Would you also call a US keyboard “virtually useless” because Shift-hyphen has to be pressed to generate an underscore, as compared to just pressing the underscore key (no shifting needed) on a Japanese keyboard? Similarly exaggerated counterclaims could be made for the circumflex ( +for all those regular expressions+ ), the at-sign ( +for all those e-mail addresses+ ), and the colon ( +for all those C trinary operators+ ) ;*) , none of which require any modifier keys to generate on a Japanese keyboard. Those facts don’t make Terminal “virtually useless” with a US keyboard. Similarly, requiring Option-¥ for a backslash, or Shift-7 for an apostrophe, or Shift-hyphen for an equals sign, wouldn’t make Terminal “virtually useless” on a Japanese keyboard.

Ironically, there is room for a backslash on my MacBook Pro’s Japanese keyboard; Shift-0 has nothing assigned to it on the keytop, and it generates a zero just like its unshifted counterpart.

In any case, that’s why I’d suggested adding that new checkbox to Terminal’s preferences; those who appreciate the ¥-to-\ substitution would be able to keep it, and those who don’t would be able to have their ¥ key (or their Option-y) work as they do everywhere else in Mac OS X.

Mar 18, 2010 6:27 PM in response to Jun T.

Jun, why do you consider Shift and Option to be completely different? Why do you view shifting as no problem, but “optioning” as problematic to the point of uselessness?

On this keyboard I have to press Option-@ and Shift-Option-@ to generate opening and closing curly double quotes. (I presume that the equivalent on a US keyboard would be Option-[ and Shift-Option-[ respectively.) I’d rather have the ability to type such characters via the Option key than not be able to type them at all — so from my perspective, the Option key is useful rather than useless.

Is it the location of the Option key that has left you underwhelmed? I find that my left pinky can easily reach both the left Shift key and the Option key. For me, the Caps key in the lower left corner is the troublesome one, which probably explains why I’d hold down a Shift key rather than use it.

Mar 19, 2010 9:26 PM in response to Jun T.

Jun, I’m not telling you that you need typing practice, and I’m not forcing you to use an Option key — all that I’m doing is trying to understand your antipathy to using an Option key.

You have a keyboard that allows you to type backslashes without modifiers, which suits your needs; that’s perfectly fine with me. I have a keyboard that doesn’t generate ¥ in Terminal under UTF-8 when pressing its ¥ key; that’s a Terminal bug. (Actually, given the identical behavior of Option-y in Terminal, we’re all affected by that bug, whichever keyboard layout we have.)

On a brighter note, I discovered [KeyRemap4MacBook|http://pqrs.org/macosx/keyremap4macbook>, which is gratis software that allows lots of different key remappings on MacBooks with various keyboard layouts. One of the built-in options for Japanese layouts is mapping the unshifted underscore to backslash (preserving Shift-underscore as underscore), which would allow programmers with Japanese keyboards easy access to the backslash even if ¥ generated ¥ in Terminal.

KeyRemap4MacBook has a debugging mode that allows observation of key presses and releases; I gave it a test run to see if there were any differences between pressing the ¥ key outside of Terminal and pressing it inside of Terminal. There wasn’t, so it seems to confirm that Terminal itself is performing the forced ¥-to-\ conversion. The similarly forced Option-y-to-\ conversion seems to indicate that it’s the ¥ character that’s being forcibly converted, rather than the particular keystrokes to generate ¥ being converted.

Mar 19, 2010 9:35 PM in response to Tom Gewecke

Tom, my theory is that it’s the ¥ character that’s forcibly being converted to \ in Terminal, rather than the ¥ keypress or the Option-y keypress to a \ keypress. Even if mapping the ¥ key to \ were desirable for all encodings in Terminal, there’s no good reason to perform the same mapping for Option-y; why forbid any keypress from generating the ¥ character?

Mar 20, 2010 12:50 AM in response to Baumkartoffel

My point is the automatic ¥ to \ conversion in Terminal.app is actually a very good feature for many, if not all, users of Japanese keyboard, I think. I have no idea why there aren't separate keys for ¥ and \ on Japanese keyboard, but under this condition I think the conversion was a good design, not a bug. But you may have a different opinion, it's OK, and I think there is no point of arguing this further. Of course there can be an option to disable the conversion.

Terminal always translates ¥ to \ in UTF-8 encoding, without checking which key is actually pressed. But if anyone ever hits option-y then chances are high that he/she wants to input ¥, not \ (because \ can be input more easily even on a Japanese keyboard, thanks to the "bug"). So it is better to translate ¥ to \ only if the ¥-key on a Japanese keyboard is pressed.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Romaji yen sign in Terminal in the UTF-8 encoding

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.