PDA

View Full Version : ASCII unprintables in strings


stuka
12-11-2002, 02:24 PM
OK, I've hunted through the ActivePerl docs, but can't figure out exactly how to get all the ASCII unprintables into a string. \0, \1, \2, and \4 work fine (with no digits following) but I can't get an <ESC> (0x1b) in any format yet...anyone know how to do this?

stuka
12-11-2002, 02:44 PM
Well, I found it myself - enough Googling got me this: http://www.ebb.org/PickingUpPerl/ (which might be a good add to the Resources thread) - turns out \000 is an octal character, and \x00 is hex. Effin' perl!

bwkaz
12-11-2002, 03:04 PM
Originally posted by Stuka
Effin' perl! Actually... that's the way that C/C++, Perl, and most likely a whole host of other languages that were incubated on a C compiler (not that I know what they are, but still), all work.

;)

stuka
12-11-2002, 04:15 PM
bwkaz: c'mon, let me vent here! ;)

stuka
12-11-2002, 06:20 PM
OK, for the curious, I hacked this together for work as a 'proof of concept' to pull down data from a web page and push it to our LED signs (all the serial port output is related to that, so don't ask, unless you want a loooooooooooooooong talk ;) ).
use LWP::Simple;
use Win32::SerialPort;

$header = "Most users ever online was .*\n";
$trailer = "</td>";
$port = new Win32::SerialPort("COM2") || die "\nCan't open COM2\n";
$port->baudrate(9600);
$port->parity("none");
$port->databits(8);
$port->stopbits(1);
$port->handshake("none");

do {
$doc = get('http://www.coderforums.net');
$doc =~ /$header(.*)$trailer/;
$list = $1;
$list =~ s/<.*?>//g;
$list =~ s/^\s+//g;
$list =~ s/,/, /g;
print($list);
$count = $port->write("\0\0\0\0\0\1Z00\2AK\e0aOnline at CoderForums now: $list\4");
print("\nWrote $count bytes\n");
sleep(10);
}while(1);

bwkaz
12-11-2002, 08:11 PM
Originally posted by Stuka
bwkaz: c'mon, let me vent here! ;)

Hey, all right, whatever... :P

(It's not like I like it that way either, but it's just the way they all work -- mostly because that's the way C worked.)