Dave Thomas wrote:
> (presumably n is in bytes, not characters)

Yes, I'm thinking bytes myself. Presumably you either want just a byte 
buffer or you know how many bytes you need to allocate for the character 
encoding you intend.