Hello forum!
I wanted to convert a string of a Lua-table to a binary file.
std::string content = "some lua table";
std::ofstream file("file.bin", std::ios::out | std::ios::binary);
file.write(content.c_str(), content.size());
Is what I do (removed valid-file-checking).
But when I serialise/use the following raw-string:
test = {
value = 24
}
the file says:
test = {
value = 24
}
after writing with the code on top.
Reading this http://en.cppreference.com/w/cpp/io/c#Binary_and_text_modes, I'm not sure if that really happened.
On paper, I understand how I can calculate a binary of some encoded character. But simply converting my string into 0s and 1s won't solve my problem, as they are still just part of some character set, right?
What I expected: Some unreadable binary-file when opening it with some text-editor.
I'm not trying to "hide" information, but I often heard to save my file as binary and this is somehow confusing me with what I learned about binary-encoding.
I would be really happy if someone could help me out, thanks a lot for your time :)! Have a sweet weekend!