use constant FB_SPACE => sub { ' ' }; $bytes = encode($charset, $chars, FB_SPACE);