I want to use StrNCopy() with a single byte character string.  I understand
that if the src string is less than n-characters in length that the dst
string gets padded to the right with NULLs.  This is good.  But if the src
is n-characters or longer then no NULL is appended to the dst string and you
don't have a NULL terminated string anymore.

What is the best way to work around this?  Simply place a NULL at the end of
the destination string every time you use this function?  Like this:

Char    dst[10];
StrNCopy(dst, "Longer than 10 bytes", 10);        // too long so no NULL us
appended
dst[9] = 0;        // always NULL the last char whether we need to or not.

-- or --

Char    dst[10];
StrNCopy(dst, "Hello", 10);        // padded with NULLs
dst[9] = 0;        // always NULL the last char whether we need to or not.


What if I want to make sure this is Multi-Byte Character friendly?  I have
no experience in that area but I am always up for making my code forward
compatible.

Thanks.




-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to