I am making my own file format. It looks like so:
<GameObjects>
{
<GameObject>
{
<int id> 0
<std::string name> GameObject0
<Transform>
{
<vec3 position> { 0, 0, 0 }
<vec3 rotation> { 0, 0, 0 }
<vec3 scale> { 1, 1, 1 }
<quat orientation> { 0, 0, 0, 1 }
<mat4 globalMatrix> { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }
<bool requiresUpdate> false
<Transform parent> -1
}
}
}
I do not want to use the '\n'
character as a delimiter when I am reading an std::string
because it would force me to use the '\n'
as part of the file format syntax. So, I came with the idea of using the '\0'
(null character) as a delimiter instead. I made the change, but now, I cannot open the file in Visual Studio (2022). I get the following error when double clicking it:
It opens in notepad with the
'\0'
represented as a whitespace, but I want to open it in Visual Studio (2022) because the editor is more powerful than notepad. Which leads to the question:
Is there a way I can see '\0'
(null character) in Visual Studio's text editor?
Update 1: File with '\0' Creator
Here is a minimal code example:
int main() {
std::cout << "Program operating" << std::endl;
std::string s;
char c = '\0';
char delimiter = ':';
std::fstream fstream = std::fstream();
fstream.open("newfile.txt");
FileData fileData = FileData(fstream);
std::ofstream ofstream = std::ofstream();
ofstream.open("newfile.txt");
ofstream << "{";
ofstream << '\0';
ofstream << "}";
ofstream.close();
fstream >> c;
fstream >> c;
fstream >> c;
fstream.close();
std::cout << "Program terminated" << std::endl;
}
If you try to open the file, Visual Studio cannot open it (at least mine)