On Wednesday, 3 September 2014 at 12:33:49 UTC, clearion wrote:
I would like to write binary data to a file for an ancillary hash table operation and then read it back using stream.rawRead(). How
would I go about converting a string to binary in D. I would
prefer not to use any third party libraries if I can. Thank You

I think this:

void main(){
    string str = "Test string";
    auto file = File("output.txt", "w");
    auto bin = cast(ubyte[])str;
    foreach(b; bin){
        file.writef("%b", b);
    }
    file.close();
}

will do it?
This is untested though....

Reply via email to