I failed to do that by code
__BEGIN__
open MyFile, ">:encoding(utf-8 )", "a.txt";
print MyFile "aaaa";
close MyFile
__END__
Question is, I want to write a visual studio solution file (.sln) which can't be recognized if it is not encoded in UTF-8 although the characters in it are all ASCII