Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jamesapp

macrumors 6502a
Original poster
Mar 7, 2008
544
0
Hello,
I was wondering if there was a way to enter control characters in a text editor for mac os x 10.6? Like if I wanted to enter control a? I tried holding down the control key and pressing the letter a key in text edit and text wrangler on my mac with no luck. I did see the ^ symbol above the 6 key and was able to write ^a but I don't know if this is the same thing as the control character? I want to send commands to a serial device, any help would be appreciated.
 
Try a backslash (escape character), ie. \a. Or you may have to enter the hexidecimal numeric equivalent for that code, see here for more info.
 
I looked at the wikipedia page. But I am looking for how to type control characters in a text editor? Like I believe control character ^A is ASCII 01 but how do I enter that in a text editor like text edit or text wrangler? In the user manual for the device it says to control the device preceed the Command with control A (Written ^A in this manual)
 
Hello,
I was wondering if there was a way to enter control characters in a text editor for mac os x 10.6? Like if I wanted to enter control a? I tried holding down the control key and pressing the letter a key in text edit and text wrangler on my mac with no luck. I did see the ^ symbol above the 6 key and was able to write ^a but I don't know if this is the same thing as the control character? I want to send commands to a serial device, any help would be appreciated.

In C, Objective-C and C++, "\001" is a string containing a single Control-A character. '\001' would be a single Control-A character; you might as well write 1 (without quotes around it).
 
I found out that I want to write a file in textwrangler so if I start the file with the numeral1 that would be the equivalent of control A? The device I want to control is a synthesizer and in the user manual it says to send a command to the synthesizer, like to change the voice if you start off with control A the synthesizer won't say the letters following the control A but will treat them as commands to control the synthesizer like changing the voice. I am a little confused in text wrangler should I start the file off with the numeral1 and that would be control A or should I start the file with '\001' without the quotes and that would be control A. I am a little confused, I did talk to a guy that said control A would look on the screen like a smile face?
 
I reread the last post, when you said you might as well use 1. You didn't mean the number one you meant one of the choices right? So if I start my file off with '\001' that would be the equivalent of control A? Just trying to figure this out. Thanks for the responses.
 
I reread the last post, when you said you might as well use 1. You didn't mean the number one you meant one of the choices right? So if I start my file off with '\001' that would be the equivalent of control A? Just trying to figure this out. Thanks for the responses.

You better tell us what you are actually trying to achieve. If you have a C function that can send a string to your modem, and you call it like send_string_to_modem ("hello"); then send_string_to_modem ("\001\002\003"); will send Control-A, Control-B, Control-C to the modem. Why do you need these characters in a file?
 
( You can modify the speech characteristics of the Nomad
Robot by sending the speech processor commands. Commands are preceeded
by a cntrl A (written ^A in this manual). This tells the processor
not to speak the following characters, but to interpret them as
commands. For Example, sending "^AV2 Hello. ^AV9 Hello." will
make the robot say hello twice, the first time softly, the second loudly.
Most commands are of the form: #A - a number and a letter.
I think ^A is ascii 01, but don't quote me on that. )

the above is from the doubletalk pc/lt user's manual. i have found out how to send a literal cntrl A in textwrangler. one thing that happened when i went to send my synthesizer a text file that started with cntrl A and then 1O (a numeral one followed by a letter O) was that my synthesizer didn't immediately say what was after the cntrl A and 1O. i used kermit, an application for communicating with a serial device. i used the transmit command and sent a text file i had written in textwrangler to my synthesizer. the text file started with cntrl A and then had 1O, which is supposed to change the voice of the synthesizer. but my synthesizer didn't say what i had written after the control sequence, "hello i am talking." i then sent another text file without the control sequence and with the words "hello i am talking" written in it. and my synthesizer said "hello i am talking" twice in a different voice than the default.
 
( You can modify the speech characteristics of the Nomad
Robot by sending the speech processor commands. Commands are preceeded
by a cntrl A (written ^A in this manual). This tells the processor
not to speak the following characters, but to interpret them as
commands. For Example, sending "^AV2 Hello. ^AV9 Hello." will
make the robot say hello twice, the first time softly, the second loudly.
Most commands are of the form: #A - a number and a letter.
I think ^A is ascii 01, but don't quote me on that. )

the above is from the doubletalk pc/lt user's manual. i have found out how to send a literal cntrl A in textwrangler. one thing that happened when i went to send my synthesizer a text file that started with cntrl A and then 1O (a numeral one followed by a letter O) was that my synthesizer didn't immediately say what was after the cntrl A and 1O. i used kermit, an application for communicating with a serial device. i used the transmit command and sent a text file i had written in textwrangler to my synthesizer. the text file started with cntrl A and then had 1O, which is supposed to change the voice of the synthesizer. but my synthesizer didn't say what i had written after the control sequence, "hello i am talking." i then sent another text file without the control sequence and with the words "hello i am talking" written in it. and my synthesizer said "hello i am talking" twice in a different voice than the default.

Reread your user's manual, and take careful note of the order of things that come after ^A. In one place you're saying the sequence is ^AV2 (ctrl-A, letter, number), then in another you're saying "Most commands are of the form: #A - a number and a letter.", which means the number comes BEFORE the command-letter.

I googled the following manual. I hope it's the one you're referring to.

http://www.vision.caltech.edu/jweber/cns286/DoubleTalkMan.txt

The examples and reference all show number-letter, but they don't say whether a space after the letter is optional or required. So try putting a space between the command-letter and any speakable text that follows it.

I also spotted this in that manual:

If text is sent to the synthesizer without a CR or Null, it will remain untranslated in the input buffer indefinitely.
So unless your text file had a terminating CR, it seems like the synthesizer was doing exactly what it was supposed to.

Frankly, I think you're just going to have to experiment with it. Be systematic, and take notes about what works and what doesn't. Welcome to debugging.
 
In the beginning of the manual they give an example ^AV1 hello. But every where else in the manual they use # A (a number followed by a letter). I tried putting a space directly after the cntrl sequence and I tried leaving the space out. Does cr stand for carriage return? I had a carriage return at the end of the text file with the cntrl sequence but didn't get immediate audio output from my synthesizer. I put a null character at the end and my synthesizer gave audio output in a different voice. Just wondering if cr stands for carriage return?
 
In the beginning of the manual they give an example ^AV1 hello. But every where else in the manual they use # A (a number followed by a letter). I tried putting a space directly after the cntrl sequence and I tried leaving the space out. Does cr stand for carriage return? I had a carriage return at the end of the text file with the cntrl sequence but didn't get immediate audio output from my synthesizer. I put a null character at the end and my synthesizer gave audio output in a different voice. Just wondering if cr stands for carriage return?

Yes, CR stands for carriage return. You need to understand ASCII and control characters. If you don't, it's like trying to discuss arithmetic without understanding what a number is.

http://en.wikipedia.org/wiki/Control_character

http://en.wikipedia.org/wiki/ASCII


Did you have a CR (hex value 0x0D) at the end of your file, or was it a LF (hex value 0x0A)? The normal Mac OS X line-ending is 0x0A, the Unix newline.

http://en.wikipedia.org/wiki/Newline

Many text editors have the ability to convert from one line-ending to another. You might want to see if your editor can do this, or use one that can.

You can see and edit hex values in a file using Hex Fiend, which I've already mentioned. I strongly suggest you get it.
 
I believe I had been using lf I would write a sentence and then hit the return key. I think that is lf, according to the last post is that lf? Not sure? I did insert cr in textwrangler by going to window pallettes ASCII table and then command clicking cr which was in the ASCII table. But when I transmitted that file i didn't get immediate audio output. I am going to get text fiend when I get a chance.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.