Browse Source

bin/pinboard: strip byte order mark

main
Brennen Bearnes 1 year ago
parent
commit
912b3b32e2
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      home/bin/pinboard

+ 8
- 1
home/bin/pinboard View File

@ -10,7 +10,8 @@ use JSON;
use Data::Dumper;
use Time::Piece;
use Carp;
use utf8;
use open qw(:std :utf8);
if ($ARGV[0] eq 'tags') {
print tags();
@ -29,6 +30,12 @@ sub tags {
my $url = 'https://api.pinboard.in/v1/tags/get?format=json&auth_token=' . $token;
my $pinboard_json = `curl -s '${url}'`;
# https://stackoverflow.com/questions/45941522/parsing-utf-8-json-with-perl
# Strip byte order mark:
# $pinboard_json =~ s/^\N{BOM}//g;
$pinboard_json =~ s/^[^\x00-\x7f]+//;
my $JSON = JSON->new->utf8->pretty;
my $pinboard_hashref = $JSON->decode($pinboard_json);
my %tags = %{ $pinboard_hashref };


Loading…
Cancel
Save