in reply to how to determine the text file encoding

You have a logic error in your premise here. This has nothing to do with BOMs. I'll explain.

According to the documentation of Encode::HanConvert, gb_to_simp takes a string encoded in GBK and returns it in UTF-8. However, your string 中国的网页 is already in UTF-8. Your testing printout confirms it. Why is it in UTF-8? It's in the source code as literal, and you declared your source code to be treated as UTF-8 by the use utf8; pragma.

If you had additionally used strict and diagnostics, you would have noticed that you're doing something wrong.

  • Comment on Re: how to determine the text file encoding