Still better

char * hb_xstrncpy( char * pDest, const char * pSource, ULONG ulLen )
{
   ULONG ulDst, ulSrc;

   pDest[ ulLen ] = 0;
   ulDst = strlen( pDest );
   if( ulDst < ulLen )
   {
      ulSrc = strlen( pSource );
      if( ulDst + ulSrc > ulLen )
         ulSrc = ulLen - ulDst;

      memcpy( &pDest[ ulDst ], pSource, ulSrc );
      pDest[ ulDst + ulSrc ] = 0;
   }
   return pDest;
}

Regards
Pritpal Bedi

-- 
View this message in context: 
http://www.nabble.com/C-and-Unicode-compliant-string-conversions-tp20721945p20726099.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to