#!/usr/bin/perl -w use open qw/:std :encoding(iso-8859-1)/; # default I/O encoding my $s = "A \N{WHITE SMILING FACE} for you\n"; open (FILE, '> fpo'); # in the actual code, may open one of several things, or assign STDOUT to FILE binmode(FILE, ':encoding(utf8)') if 1; # override the default encoding under certain conditions warn "About to print"; # primitive trace statement print FILE "$s"; #### About to print at ./fp line 11. "\x{263a}" does not map to iso-8859-1.