build: always use utf-8 when reading/writing text files

open() in text mode should never be used without an encoding because it defaults
to the locale encoding which is rarely what is wanted.

This fixes the Windows build in some cases (depending on the locale/paths used)
4 jobs for gtk3-build-explicit-encoding in 21 minutes and 18 seconds (queued for 1 second)
Status Job ID Name Coverage
  Build
passed #336639
fedora-autotools

00:09:55

passed #336640
fedora-meson

00:10:47

manual #336642
win32 allowed to fail manual
msys2-mingw32-autotools
passed #336641
win32
msys2-mingw32-meson

00:21:18