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

Merged Christoph Reiter requested to merge creiter/gtk:gtk3-build-explicit-encoding into gtk-3-24

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)

Merge request reports