On Visual Studio 2015 at least, the 'n' parameter is the number of characters, not the number of bytes. This is relevant for wide char streams in particular.