[minor] Automatically set the correct encoding of the source stream if it's not set