Another option you could do - and probably a better one - is to allow the user to specify their preferred character encoding in the .rc. Then, you run that value through Encode::resolve_alias() to make sure it exists and is supported by Encode, and use the returned value in the open() call instead of "utf-8".
That'll cause Perl to read the file as if in that character encoding and convert it on-the-fly to UTF-8 internally. You'll then have UTF-8 data that you can send to the server. :)
Re: no apologies needed, thank you for pointing that out
Encode::resolve_alias()
to make sure it exists and is supported by Encode, and use the returned value in theopen()
call instead of "utf-8".That'll cause Perl to read the file as if in that character encoding and convert it on-the-fly to UTF-8 internally. You'll then have UTF-8 data that you can send to the server. :)