It seems simple to me - if you want bytes, open the file in binary mode, if you want strings open it in text mode.<p>The only glitch is with stdin&#x2F;stdout. They&#x27;re opened on your behalf before your program even starts, and the assumption is that you&#x27;ll be reading and writing text in the default OS encoding. This doesn&#x27;t mesh well with the Unix pipe paradigm.