file io - C++ FileIO weird behaviour -
while writing program came accross strange behaviour of std::ofstream
. please refer code below
ofstream dire; dire.open("dir.txt", std::ios::out); // other code for(int i=0;i<dir.size();i++) { dire << dir[i] << "\t"; // dir integer vector containing values between 0-9 }
now when open dir.txt
contents are:
ऴऴऴऴवववववववववशशशशशशशशशशषषषषषषषषरररररररऱऱऱऱऱऱऱऱऱललललललललललललळ.. , on
if give space , tab(\t) works correctly or matter \n works correctly. dire << dir[i] << " \t";
and output is:
4 4 4 4 5 5 5 5 5 5.. , on
i tried dire.flush()
flush output buffer file, still same result.
i can away using \t
learn why happening.
if using notepad @ file bug bush hid facts can problem.
the bug occurs when string passed win32 charset detection function istextunicode no other characters. istextunicode sees thinks valid utf-16le chinese , returns true, , application incorrectly interprets text utf-16le.
Comments
Post a Comment