The Crystal programming language and encodings

Recently I found myself struggling with setting up file encodings correctly in the Crystal programming language, this is why I document this here. Crystal defaults to reading and writing files in UTF-8. Sometimes you will encounter files encoded in e.g. the Windows-1252 code page. (This is the western european code page, e.g. used for German [...]