> Thanks! But it will work only for text, what about binary files?
> 
> Not an expert, but afaik string is just a sequence of chars and char is 
> always a byte. Thus you just staticRead and then may access each byte using 
> subscript []. Haven't heard about other ways of dancing with bytes in nim :/

Nim opens files always in binary mode. Standard library functions like e.g. 
`splitLines` cope with all kinds of line endings, you don't have to worry about 
that.

So basically you can use strings just as binary blobs but it's recommended to 
use `seq[byte]` for them 
instead([https://forum.nim-lang.org/t/3173#20096)](https://forum.nim-lang.org/t/3173#20096\)).
 You can convert strings to `seq[byte]` by using `cast[seq[byte]](myString)`. I 
don't know if this behavior is guaranteed somewhere, I just picked it up from 
Nim code by others(it probably won't work when compiling to JS or when using 
Nimscript).

Reply via email to