---
name: "SDL_iconv"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_iconv"
---

# SDL\_iconv(3)

This function converts text between encodings, reading from and writing to a buffer.

## NAME

SDL\_iconv - This function converts text between encodings, reading from and writing to a buffer.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**size\_t SDL\_iconv(SDL\_iconv\_t cd, const char \*\*inbuf,**              **size\_t \*inbytesleft, char \*\*outbuf,**              **size\_t \*outbytesleft);** **#define SDL\_ICONV\_ERROR     (size\_t)-1  /\*\*\< Generic error. Check SDL\_GetError()? \*/** **#define SDL\_ICONV\_E2BIG     (size\_t)-2  /\*\*\< Output buffer was too small. \*/** **#define SDL\_ICONV\_EILSEQ    (size\_t)-3  /\*\*\< Invalid input sequence was encountered. \*/** **#define SDL\_ICONV\_EINVAL    (size\_t)-4  /\*\*\< Incomplete input sequence was encountered. \*/**

## DESCRIPTION

It returns the number of succesful conversions on success. On error,

**SDL\_ICONV\_E2BIG**\
  is returned when the output buffer is too small, or  **SDL\_ICONV\_EILSEQ**\
  is returned when an invalid input sequence is encountered, or

**SDL\_ICONV\_EINVAL**\
  is returned when an incomplete input sequence is encountered.

On exit:

• inbuf will point to the beginning of the next multibyte sequence. On\
   error, this is the location of the problematic input sequence. On\
   success, this is the end of the input sequence.

• inbytesleft will be set to the number of bytes left to convert, which\
   will be 0 on success.

• outbuf will point to the location where to store the next output byte.

• outbytesleft will be set to the number of bytes left in the output\
   buffer.

## FUNCTION PARAMETERS

- *cd*

  The character set conversion context, created in  **SDL\_iconv\_open** ().

- *inbuf*

  Address of variable that points to the first character of the input sequence.

- *inbytesleft*

  The number of bytes in the input buffer.

- *outbuf*

  Address of variable that points to the output buffer.

- *outbytesleft*

  The number of bytes in the output buffer.

## RETURN VALUE

Returns the number of conversions on success, or a negative error code.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_iconv\_open**(3)](/SDL_iconv_open/3.md), **•**(3), [**SDL\_iconv\_close**(3)](/SDL_iconv_close/3.md), **•**(3), [**SDL\_iconv\_string**(3)](/SDL_iconv_string/3.md)
