Always set the locale first ... do locale::global( locale( "" ) );. Prior to this, you are in simple C mode, which knows nothing about UTF-8.
In Darwin, this is broken, so I need to do it setlocale( LC_ALL, "" );, but then your program works for me.
Edit
, . wfstream openmode . wofstream , , . . :
wofstream out("/tmp/unicode.txt");
wfstream out("/tmp/unicode.txt", ios::in | ios::out | ios::trunc );