Guest User

Untitled

a guest
Jun 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. use strict;
  2. use utf8;
  3.  
  4. # convert unicode to Decimal NCR format
  5. sub convertUnicodeToDecimalNCR {
  6. my ($self, $str) = @_;
  7. # important
  8. utf8::decode($str);
  9. my $ret_str = "";
  10. while ($str =~ /(.)/g) {
  11. my $c = $1;
  12. my $b = ord($c);
  13. if ($b > ord('z') && $b ne 123 && $b ne 125 && $b ne 126) {
  14. $ret_str .= "&#".$b.";";
  15. } else {
  16. $ret_str .= $c;
  17. }
  18. }
  19. # $str =~ s/./"&#".ord($&).";" if /eg;
  20. return $ret_str;
  21. }
Add Comment
Please, Sign In to add comment