Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Last active December 16, 2015 06:10
Show Gist options
  • Select an option

  • Save xtetsuji/5389839 to your computer and use it in GitHub Desktop.

Select an option

Save xtetsuji/5389839 to your computer and use it in GitHub Desktop.
Mac::Pasteboard (Version 0.0004) can not handling multibyte UTF-8 characters.
#!/usr/bin/env perl
# This document is UTF-8
use strict;
use warnings;
use bytes; # UTF-8 bytestream
use Mac::Pasteboard;
my $snowman = "☃☃☃";
system(qq{echo "$snowman" | pbcopy});
print "try pbpaste.\n";
print "LANG=$ENV{LANG}\n";
print "Mac::Pasteboard Version is $Mac::Pasteboard::VERSION\n";
print "command pbpaste => " . (`pbpaste`) . "\n";
print "Mac::Pasteboard::pbpaste() => " . (Mac::Pasteboard::pbpaste()) . "\n";
print "\n";
print "try pbcopy\n";
system(qq{echo "INIT" | pbcopy});
Mac::Pasteboard::pbcopy($snowman);
print "command pbpaste => " . (`pbpaste`) . "\n";
print "Mac::Pasteboard::pbpaste() => " . (Mac::Pasteboard::pbpaste()) . "\n";
print "\n";
__END__
MY_OUTPUT:
try pbpaste.
LANG=ja_JP.UTF-8
Mac::Pasteboard Version is 0.004
command pbpaste => ☃☃☃
Mac::Pasteboard::pbpaste() => &&&
try pbcopy
command pbpaste => ☃☃☃
Mac::Pasteboard::pbpaste() => ☃☃☃
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment