Friday, 15 April 2011

file io - C++ FileIO weird behaviour -


While writing a program I came across the strange behavior of std :: ofstream Refer to the code

  Strictly; Dire.open ("dir.txt", std :: IOS :: out); // some other code (int i = 0; i & lt; dir.size (); i ++) {terrible & lt; & Lt; DIR [I] & lt; & Lt; "\ T"; // dir is the integer vector in which there are values ​​between 0-9}  

Now when I open the dir.txt content:

  If I give a space and then the tab (\ t) then it works correctly or \ n also works correctly for that matter.  Strict & lt; & Lt; DIR [I] & lt; & Lt; "\ T";  

And now the output is:

  4 4 5 5 5 5 5 5 .. and so on  

I also tried to flush the output buffer to dire.flush () file, but still the same result.

I'm definitely using the \ t , but I would like to know why this is happening.

There may be a bug problem if you are using Notepad to view the file.

A bug occurs when the string is executed with the other characters without the Win32 charset recognition function IsTextUnicode IsTextUnicode sees that it is valid whether the UTF-16LE Chinese is valid and it returns the correct returns , And this application incorrectly interprets text as UTF-16LE.


No comments:

Post a Comment