translate_string()

translate_string()#

translate_string replaces characters in the from string with corresponding characters from the mk_to string, based on the mapping defined in mk_from.

Prototype

char *translate_string(
    char *to,
    int   tolen,
    const char *from,
    const char *mk_to,
    const char *mk_from
);

Parameters

Key

Type

Description

to

char *

Buffer to store the translated string.

tolen

int

Size of the to buffer.

from

const char *

Input string containing characters to be replaced.

mk_to

const char *

String containing replacement characters.

mk_from

const char *

String containing characters to be replaced.


Return Value

Returns a pointer to the to buffer containing the translated string.

Notes

[‘The mk_from and mk_to strings define a mapping where each character in mk_from is replaced by the corresponding character in mk_to.’, ‘If tolen is too small, the function may not fully translate the input.’, ‘The function does not allocate memory; the caller must ensure to has sufficient space.’]

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples