0

I'm a newbie in WinApi programming. I'm creating a file mapping program. A user enters some string to the input and this text has to be put into a file. But in the file I get strange white spaces between each symbol. For instance, if I enter "Some text", I get "S o m e t e x t". Why is it?

pBuf = (LPTSTR)MapViewOfFile(fileMap, FILE_MAP_ALL_ACCESS, 0, 0, 10240000);
...
GetWindowText(teacherInput, teacher, 31);
memcpy((PVOID)pBuf, teacher, 31 * charSize);
serg66
  • 1,148
  • 1
  • 17
  • 31
  • 4
    I bet you are creating a UTF-16 file but reading it as UTF-8. View the `teacher` buffer in memory, and check out the value of `charSize`. – Raymond Chen Nov 23 '14 at 15:28

1 Answers1

0

As Raymond Chen stated in the comments, this happend because the encodings don't match.

serg66
  • 1,148
  • 1
  • 17
  • 31