From 9772d0512c8a0bb1841244ef9043e598ba0c0ff7 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 24 Sep 2023 17:27:23 -0700
Subject: [PATCH] SDL_iconv_string() defaults to UTF-8
Fixes https://github.com/libsdl-org/SDL/issues/8287
(cherry picked from commit 1375d2049d9fd17cb0d9a47a0e256a42c3188f76)
---
src/stdlib/SDL_iconv.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c
index fd706dbcbb44..30a611e592d2 100644
--- a/src/stdlib/SDL_iconv.c
+++ b/src/stdlib/SDL_iconv.c
@@ -795,17 +795,13 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
size_t outbytesleft;
size_t retCode = 0;
- cd = SDL_iconv_open(tocode, fromcode);
- if (cd == (SDL_iconv_t)-1) {
- /* See if we can recover here (fixes iconv on Solaris 11) */
- if (tocode == NULL || !*tocode) {
- tocode = "UTF-8";
- }
- if (fromcode == NULL || !*fromcode) {
- fromcode = "UTF-8";
- }
- cd = SDL_iconv_open(tocode, fromcode);
+ if (tocode == NULL || !*tocode) {
+ tocode = "UTF-8";
+ }
+ if (fromcode == NULL || !*fromcode) {
+ fromcode = "UTF-8";
}
+ cd = SDL_iconv_open(tocode, fromcode);
if (cd == (SDL_iconv_t)-1) {
return NULL;
}