#!/usr/bin/env perl

sub encode {
    my $data = shift;

    $data =~ s/([^\w ])/'\\x' . unpack('H2', $1)/eg;

    return $data;
}

while (my $line = <>) {
    if ($line =~ /^#define /) {
        $line =~ s/"(.+)"\r\n$/'"' . encode($1) . '"' . "\r\n"/e;
    }
    print $line;
}
