I want to read a name from stdin/cin and write this name to a file. The problem is that the name can contain umlaute (ÄäÖöÜüß).
I am working with cygwin. Until one year, when I made an update, it worked fine. On an older machine with the old cygwin it still works, but on my actual machine with the newest cygin packages it doesn't. I could test the code even on an actual Ubuntu system 10.10 with the same wrong output.
How is the file encoded? (UTF-8? MS "Extended ASCII"? etc?)
What code do you use to read the file?
How do you store the string? (std::string? wchar_t s[N]? etc?)
How do you display it? (cout? wxSomething? etc?) [code please]
The only code I use is the code above. I don't have any extra code!
That means I don't read any file. I just take the input from cin and write it to a file as you can see above. The result of the new file is read with 'cat' - if that's what you asked for.
The files are written directly from the program. So I don't know where I can set the type of file encoding.
It seems I wasn't paying enough attention the first time around.
The problem is that your OS handles input using UTF-8 encoding, and the 'ä' letter takes twochars to encode and not just one. So when you assume that every letter takes exactly one char then your code breaks...
Since your code is concerned with space requirements, it is behaving correctly.