Advertisement
Guest User

p6 unicode problem

a guest
Jan 28th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.14 KB | None | 0 0
  1. # generate sample input
  2. cat > /tmp/sample.input <<EOF
  3. Musopen%20DVD/Brahms%20-%20Symphony%20No%201%20in%20C%20Major/Symphony%20No.%201%20in%20C%20Minor,%20Op.%2068%20-%20IV.%20Adagio%20-%20Piu%CC%80%20andante%20-%20Allegro%20non%20troppo,%20ma%20con%20brio.mp3
  4. EOF
  5.  
  6. # generate sample output
  7. perl -E 'print chr for 77,117,115,111,112,101,110,32,68,86,68,47,66,114,97,104,109,115,32,45,32,83,121,109,112,104,111,110,121,32,78,111,32,49,32,105,110,32,67,32,77,97,106,111,114,47,83,121,109,112,104,111,110,121,32,78,111,46,32,49,32,105,110,32,67,32,77,105,110,111,114,44,32,79,112,46,32,54,56,32,45,32,73,86,46,32,65,100,97,103,105,111,32,45,32,80,105,117,204,128,32,97,110,100,97,110,116,101,32,45,32,65,108,108,101,103,114,111,32,110,111,110,32,116,114,111,112,112,111,44,32,109,97,32,99,111,110,32,98,114,105,111,46,109,112,51,10' > /tmp/sample.output
  8.  
  9. # attempt translate
  10. perl6 -e 'S:g/"%" ( <xdigit>**2)/{ :16(~$0).chr }/.say given "/tmp/sample.input".IO.slurp()' | diff -sq - /tmp/sample.output
  11.  
  12. # legacy translare
  13. perl -MFile::Slurp -e 'print(read_file("/tmp/sample.input") =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/egr)' | diff -sq - /tmp/sample.output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement