Crystal 0.12.0 has been released!
The major feature of this release is IO encoding support.
Strings in Crystal always denote UTF-8 encoded characters. Before this release, if you read a file whose encoding wasn’t UTF-8 the String ended with invalid byte sequences, and there was no way to specify the encoding.
Now you can do it, both for writing and reading. For example, to read a file encoded in, say, GB2312, you do:
The encoding can be set on all IOs (files, sockets, pipes, memory):
Additionally, HTTP::Client will use the charset specified in the Content-Type header so you can now fetch non-UTF-8 web sites.
comments powered by Disqus