Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How to remove an apostrophe?

by liverpole (Monsignor)
on Oct 12, 2005 at 19:04 UTC ( #499646=note: print w/ replies, xml ) Need Help??


in reply to How to remove an apostrophe?

To make sure the characters in the filename are what you think they are, try something like this to decipher $newName:

map { printf "Char(%s) = Ascii %d\n", $_, ord $_ } split //, $newName;
For reference, you can also display an ascii chart (showing hex, decimal and the character) with:
map {printf"%3d %2x %2s|",$_,$_,$_<32?'^'.chr$_+64:$_<127?chr$_:'^?'} +(0..127);
which displays:
  0  0 ^@|  1  1 ^A|  2  2 ^B|  3  3 ^C|  4  4 ^D|  5  5 ^E|  6  6 ^F|  7  7 ^G|
  8  8 ^H|  9  9 ^I| 10  a ^J| 11  b ^K| 12  c ^L| 13  d ^M| 14  e ^N| 15  f ^O|
 16 10 ^P| 17 11 ^Q| 18 12 ^R| 19 13 ^S| 20 14 ^T| 21 15 ^U| 22 16 ^V| 23 17 ^W|
 24 18 ^X| 25 19 ^Y| 26 1a ^Z| 27 1b ^[| 28 1c ^\| 29 1d ^]| 30 1e ^^| 31 1f ^_|
 32 20   | 33 21  !| 34 22  "| 35 23  #| 36 24  $| 37 25  %| 38 26  &| 39 27  '|
 40 28  (| 41 29  )| 42 2a  *| 43 2b  +| 44 2c  ,| 45 2d  -| 46 2e  .| 47 2f  /|
 48 30  0| 49 31  1| 50 32  2| 51 33  3| 52 34  4| 53 35  5| 54 36  6| 55 37  7|
 56 38  8| 57 39  9| 58 3a  :| 59 3b  ;| 60 3c  <| 61 3d  =| 62 3e  >| 63 3f  ?|
 64 40  @| 65 41  A| 66 42  B| 67 43  C| 68 44  D| 69 45  E| 70 46  F| 71 47  G|
 72 48  H| 73 49  I| 74 4a  J| 75 4b  K| 76 4c  L| 77 4d  M| 78 4e  N| 79 4f  O|
 80 50  P| 81 51  Q| 82 52  R| 83 53  S| 84 54  T| 85 55  U| 86 56  V| 87 57  W|
 88 58  X| 89 59  Y| 90 5a  Z| 91 5b  [| 92 5c  \| 93 5d  ]| 94 5e  ^| 95 5f  _|
 96 60  `| 97 61  a| 98 62  b| 99 63  c|100 64  d|101 65  e|102 66  f|103 67  g|
104 68  h|105 69  i|106 6a  j|107 6b  k|108 6c  l|109 6d  m|110 6e  n|111 6f  o|
112 70  p|113 71  q|114 72  r|115 73  s|116 74  t|117 75  u|118 76  v|119 77  w|
120 78  x|121 79  y|122 7a  z|123 7b  {|124 7c  ||125 7d  }|126 7e  ~|127 7f ^?|


Comment on Re: How to remove an apostrophe?
Select or Download Code
Re^2: How to remove an apostrophe?
by PrakashK (Pilgrim) on Oct 13, 2005 at 15:04 UTC
    map {printf"%3d %2x %2s|",$_,$_,$_<32?'^'.chr$_+64:$_<127?chr$_:'^?'} +(0..127);

    Cool (and useful) one-liner, replacing man ascii!

    I added it to my ~/.bash/functions, with a few changes replace the quote chracters so it would be acceptable to bash. Also, added a newline for every 8 characters.

    function ascii { perl -e ' map { printf q{%3d %2X %2s|%s}, $_, $_, $_<32 ? q{^}.chr($_+64) : $_<127 ? chr : q{^?}, ($_+1)%8 ? q{} : $/ } 0..127 ' }

    /prakash

    PS: I tried making it a bash alias, but it was too much trouble working around all those quotes to prevent bash interpolating $_ etc!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://499646]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-04 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls