# _CP_iconv

_CP_iconv is equivalent to the `*result* = iconv(*string1*, *string2*)` BASIC statement.

## Syntax

```
int _CP_iconv(CPSTR** result, CPSTR* string1, CPSTR* string2)
```

## Description

This function returns -1 if
an error occurs. The error code is contained in _CP_errno.

Note: This function is provided for convenience only. It requires
considerable amounts of CPU, as it must parse the format string (string2) at run time (which is also true of the UNIX printf() function). Unless contact with the D3 environment
is absolutely required for the conversion, it is suggested that users
write their own formatting routines to address their specific requirements
in a more efficient manner.

## Example(s)

```
/* Prints "a". */

CPSTR * s = _CP_mkstr("a2");
CPSTR * t = _CP_mkstr("mca");

_CP_iconv(&s,s,t);
_CP_print(s);
```

## See also

- [C functions overview](https://d3codex.com/cfunctions/c-functions-overview/)

---
Source: https://d3codex.com/cfunctions/cp-iconv/ - part of the D3Codex reference.
