As far as I know, perl ignores the LC environment variables. Is it possible that you have perl reading multibyte characters as multiple bytes and passing those bytes verbatim to the file, and then the LC variables are affecting how you
those bytes? If that’s the case, your perl program is producing the correct output (for the wrong reasons) but maybe you don’t really need to do anything about it.