unicode char on command line

I have a folder that contains a non-ASCII character, "registered sign" (®), which can be typed in Terminal using option-r.

It's U+00AE, and as an 8-bit character it's decimal 174. I want to be able to enter that character on the command line without

typing Option, because I need to build a Terminal command using an application that

isn't Unicode-friendly. Thus option-r doesn't help me create a string containing that character.


For example, in Terminal I made a folder in ~ with <option-r> as its entire name (I typed an r while holding the option key):


> mkdir ~/<option-r>


I can list it using


> ls ~/<option-r>


but I need to be able to do that *without using any modifier keys* (like option).


I thought I could use something like (after cd ~)


> ls \302\256


or


> ls \u00AE


or


> ls \xc2\xae


but I haven't been able to make the shell interpret what I type as the registered r symbol. Whatever I enter is interpreted

literally as individual characters instead of, e.g., \xC2 being taken as a single character. I've also tried various combinations

of quotation marks as well as doubling the backslash, but I keep getting "No such file or directory".


How can I represent this character on the command line without modifier keys? I'm using El Capitan, OS X 10.11.2, running bash 3.2.

Mac Pro, OS X El Capitan (10.11), Mid 2012

Posted on Jan 6, 2016 9:53 AM

Reply
3 replies

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.

unicode char on command line

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