IIS と PHP 7.x 系で動いているソフトを PHP 8.2 で動かそうと思うと、以下のようなエラーが出た。

PHP Fatal error:  Could not convert the script from the detected encoding "UTF-8" to a compatible encoding in ほにゃらら on line ほにゃらら

以後、他の PHP スクリプト(例えば phpinfo() を実行するだけのスクリプト) を実行させてもエラーが出続ける。(IIS を再起動しないと復旧しない)

require_once の行でエラーとなっていた。

require_once しているファイルに ef bb bf の BOM (UTF-8 を示す) が付いていた。

このファイルを dos2unix で変換すると動作するようになった。

dd if=in_file of=out_file bs=1 skip=3

で BOM を取っても動作する。