Useful Perl script – convert text to ascii

Problem

You want to convert text to ascii values.



Solution

Perl script to convert standard input to ascii values, useful with web code.

You can take the output and insert directly into HTML pages.

#!/usr/bin/perlwhile(sysread(STDIN,$a,1)) {$c=ord($a);if($c==10) { print "n"; } else { print "&#$c;"; }}exit(0);__END__


Example


Here is a screen shot:

convert characters to ascii values in perl



Reference



1 thought on “Useful Perl script – convert text to ascii”

  1. Thank you hoodia. I’m glad you found the information you were looking for. Tell all your friends to visit techie-blogs.com too!! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *