Useful Perl script – convert text to ascii

[problem]

You want to convert text to ascii values.

[/problem]

[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/perl  while(sysread(STDIN,$a,1)) {  $c=ord($a);if($c==10) { print "n"; } else { print "&#$c;"; }  }  exit(0);  __END__ 

[/solution]

[example]

Here is a screen shot:

convert characters to ascii values in perl

[/example]

[reference]

[/reference]

If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

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