Skip to content

Instantly share code, notes, and snippets.

@knbknb
Last active April 15, 2022 17:20
Show Gist options
  • Select an option

  • Save knbknb/ab74772fd8e66447964dc4926339fc23 to your computer and use it in GitHub Desktop.

Select an option

Save knbknb/ab74772fd8e66447964dc4926339fc23 to your computer and use it in GitHub Desktop.
perl: humanreadable display of UTF-8 characters in terminal
#!/usr/bin/perl
# Convert \u1234 sequences (e.g. from Wikipedia)
# to characters the terminal can display.
#
# example call:
# curl -sL -H "Accept: text/turtle" "http://dbpedia.org/resource/Pudding" | uni2utf8.pl
use strict;
use warnings;
binmode(STDOUT, ':utf8');
while (<>) {
s/\\u([0-9a-fA-F]{4})/chr(hex($1))/eg;
print;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment