Hello, I am wondering how to write the null character in terminal?

Hello,


I have a MacBook pro laptop running lion.


I wondered how to write the null character in terminal text edit textwrangler etc.

Posted on Aug 28, 2011 2:50 PM

Reply
8 replies

Sep 1, 2011 6:55 AM in response to jamesfromlowville

Hello,


Thanks for the response. I have an external speech synthesizer i am trying to test. I want to use the cat and echo command to send text out to my synthesizer.


I have a usb2serial adaptor, and its driver. So if i use the echo command how would i end a line of text with a null character?


Like if i type


echo testing, one, two, three $'/0'


Would terminal recognize the null character?


I am gonna try that now. Another thing sometimes i use the set command to set up communication with the synthesizer. Set speed 9600, set carrier-watch off etc. I am trying to test a synthesizer. I had it working awhile back. But cant remember the exact set-up that worked.


My goal right know is to use the cat and echo command, right a line of text ending with a nul character, redirect it to my usb2serial adaptor and hopefully have my synthesizer speak the line.


Anyway any further help would be great.

Sep 1, 2011 2:04 PM in response to jamesfromlowville

Hello


When i type:


echo hello, i am talking $'\0' > /dev/**.usbserial-FTKVMAFF


In terminal i get no output from my speech synthesizer, but when i go into a text editor like text edit, or when i put a null character directly into the terminal from show character viewer. Which i enabled in system preferences. I get audio output.


So i am wondering if there is a way to enter a null character from my terminal keyboard? I think in the bash shell the only command line option is -n, which has something to do with a newline. In my notes i have written


echo -n -e


And i believe the -e is for the terminal to recognize special escape sequences. So i am going to try to open an sh shell and man the echo command.


Btw my synthesizer will also recognize the carriage return, would you happen to know how to produce that. I can get it from character viewer but am looking for a keyboard shortcut?

Sep 1, 2011 6:47 PM in response to jamesfromlowville

From: http://superuser.com/questions/293260/how-can-i-write-the-null-character-on-a-ma cbook-pro


You can do this with the Unicode Hex Input method (enable it in System Preferences -> Language & Text pane -> Input Sources tab, then select it from the menu item) by holding Option and typing "0000".

Warning: the null character is not allowed in C-language strings (it's used to indicate the end of the string), so not all programs will cope with it. In TextEdit, for example, you can insert a null into a document, but when you save the document it'll only save the part before the null.

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.

Hello, I am wondering how to write the null character in terminal?

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