I'm working on Ubuntu 16.04 (Xenial Xerus). I found out that text editors write additional bytes (UTF-8) to the text file. It made some problems for me, when I tried to pass tests.
So we have a string, "Extra byte", with the size = 10 bytes in UTF-8. When I try to write it in file by gedit, for example, I get a file with the size = 11 byte. Also, nano makes the same size. Even "echo "Extra byte" > filename" returns 11 bytes.
However, when we try something like this:
#include <fstream>
int main(){
std::ofstream file("filename");
file<<"Extra byte";
return 0;
}
or this:
with open("filename_py",'w+',encoding='UTF-8') as file:
file.write('Extra byte')
We get the file with size = 10 bytes. Why?