---
name: "SDL_iconv_string"
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_string"
---

# SDL\_iconv\_string(3)

Helper function to convert a string's encoding in one call.

## NAME

SDL\_iconv\_string - Helper function to convert a string's encoding in one call.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

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

**char \* SDL\_iconv\_string(const char \*tocode,**                    **const char \*fromcode,**                    **const char \*inbuf,**                    **size\_t inbytesleft);**

## DESCRIPTION

This function converts a buffer or string between encodings in one pass.

The string does not need to be NULL-terminated; this function operates on the number of bytes specified in **inbytesleft** whether there is a NULL character anywhere in the buffer.

The returned string is owned by the caller, and should be passed to

**SDL\_free**\
  when no longer needed.

## FUNCTION PARAMETERS

- *tocode*

  the character encoding of the output string. Examples are "UTF-8", "UCS-4", etc.

- *fromcode*

  the character encoding of data in **inbuf** .

- *inbuf*

  the string to convert to a different encoding.

- *inbytesleft*

  the size of the input string \_in bytes\_.

## RETURN VALUE

Returns a new string, converted to the new encoding, or NULL on error.

## 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**(3)](/SDL_iconv/3.md)
