sdlIconvString function

Pointer<Int8> sdlIconvString(
  1. String? tocode,
  2. String? fromcode,
  3. String? inbuf,
  4. int inbytesleft,
)

This function converts a buffer or string between encodings in one pass, returning a string that must be freed with SDL_free() or NULL on error.

\since This function is available since SDL 2.0.0.

extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)

Implementation

Pointer<Int8> sdlIconvString(
    String? tocode, String? fromcode, String? inbuf, int inbytesleft) {
  final sdlIconvStringLookupFunction = libSdl2.lookupFunction<
      Pointer<Int8> Function(Pointer<Utf8> tocode, Pointer<Utf8> fromcode,
          Pointer<Utf8> inbuf, Uint32 inbytesleft),
      Pointer<Int8> Function(Pointer<Utf8> tocode, Pointer<Utf8> fromcode,
          Pointer<Utf8> inbuf, int inbytesleft)>('SDL_iconv_string');
  final tocodePointer = tocode != null ? tocode.toNativeUtf8() : nullptr;
  final fromcodePointer = fromcode != null ? fromcode.toNativeUtf8() : nullptr;
  final inbufPointer = inbuf != null ? inbuf.toNativeUtf8() : nullptr;
  final result = sdlIconvStringLookupFunction(
      tocodePointer, fromcodePointer, inbufPointer, inbytesleft);
  calloc.free(tocodePointer);
  calloc.free(fromcodePointer);
  calloc.free(inbufPointer);
  return result;
}