CAPL Script

MbStrnCpy

Syntax

void mbstrncpy(char dest[], char src[], long len);

void mbstrncpy_off(char dest[], long destOffset, char src[], long len);

Function

mbstrncpyfunction copiessrctodest.lenindicates the number ofcharactersthat shall be copied; use -1 to indicate that as much shall be copied intodestas will fit (maximum until the end ofsrc). The function ensures that there is a terminating 0 byte; but in contrast to strncpy, that byte is not counted intolen. mbstrncpy_offoverwrites characters in the destination buffer starting at the character offset destOffset.

Parameters

dest Destination buffer

src

Source string

len

Number ofcharactersto be copied, or -1 to copy as much as possible

destOffset

Offset incharactersinto the destination buffer

Return Values

char s1[50] = "eine grüne "; // german for 'a green'char s2[10] = "Türen"; // german for 'doors'mbstrncpy_off(s1, 11, s2, 3);write("%s", s1); // eine grüne Tür (german for 'a green door')

strncpy | mbstrlen | mbstrncmp | mbstrstr