my $UnsafeChar = 'οι'; print encode_entities(decode ('utf-8', $TestStr), decode ('utf-8', $UnsafeChar)) . "\n";