This section contains some useful notes about managing the input and output buffers used by the codepage conversion functions.
Determining Buffer Size
When creating the output buffers for the conversion functions, care must be taken to ensure that the buffer is large enough for the entire converted output, plus a terminating null character.
If you wish to use your buffer for conversion to any arbitrary codepage, the best practise is to use a buffer size of four times the length of the input Unicode string (plus one byte for the terminating null).
Using Length Parameters
The two different sets of conversion functions differ in how they treat their respective buffer length parameters.