# zig fmt: factorize source file reading and decoding · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/8942243f7a825e42c16c8d210f5f9dc3baa76b2f)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 8942243f7a825e42c16c8d210f5f9dc3baa76b2f

Requested commit: 8942243f7a825e42c16c8d210f5f9dc3baa76b2f

Commit: 8942243f7a825e42c16c8d210f5f9dc3baa76b2f

Tree: ae67b24aeacd992e1a382e349d9b51d474bf3307

Author: Ersikan

Committer: Ersikan

## Message

```
zig fmt: factorize source file reading and decoding

Now reading a source file and decoding it from UTF-16LE to UTF-8 is
done in a single function. Error messages are improved, and an error is
emitted when the source file has a BOM not supported (UTF-16BE, UTF-32).

Please note that the BOM of UTF-32 is composed of the same bytes as the
BOM of UTF-16 followed by a null character. Therefore a source file in
UTF-16LE starting with a null byte will be interpreted as an UTF-32, and
rejeted because of an invalid format. In pratice this is not a problem,
as the code would have been rejected later anyway because of the null
character.

```

## Parents

- [a3540000909bdc6a59ba07c85d21afeb3a7e54e2](https://git.cafe/gitcafe/zig/commit/a3540000909bdc6a59ba07c85d21afeb3a7e54e2?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/8942243f7a825e42c16c8d210f5f9dc3baa76b2f?format=markdown)
