From 7051b9e563f7cdf5e09e65a33b5ac0152061e541 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 25 Jun 2016 21:24:45 +0100 Subject: [PATCH] Use libiconv instead of newlib's iconv Requires invalid input to be explicitly ignored, as unlike newlib invalid characters are not replaced with '?' Fixes bug 2440 --- frontends/amiga/Makefile.defaults | 6 +----- frontends/amiga/utf8.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/frontends/amiga/Makefile.defaults b/frontends/amiga/Makefile.defaults index 0674a9de2..186498132 100644 --- a/frontends/amiga/Makefile.defaults +++ b/frontends/amiga/Makefile.defaults @@ -4,11 +4,7 @@ # Force using glibc internal iconv implementation instead of external libiconv # Valid options: YES, NO -ifneq ($(SUBTARGET),os3) - NETSURF_USE_LIBICONV_PLUG := YES -else - NETSURF_USE_LIBICONV_PLUG := NO -endif +NETSURF_USE_LIBICONV_PLUG := NO # Enable NetSurf's use of librosprite for displaying RISC OS Sprites # Valid options: YES, NO, AUTO diff --git a/frontends/amiga/utf8.c b/frontends/amiga/utf8.c index d48e073fd..5d05e9535 100755 --- a/frontends/amiga/utf8.c +++ b/frontends/amiga/utf8.c @@ -16,10 +16,15 @@ * along with this program. If not, see . */ +#include "amiga/os3support.h" + #include #include #include +#include +#include + #include "utils/nsoption.h" #include "utils/utf8.h" #include "netsurf/utf8.h" @@ -33,7 +38,13 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result) nserror utf8_to_local_encoding(const char *string, size_t len, char **result) { - return utf8_to_enc(string, nsoption_charp(local_charset), len, result); + nserror err = NSERROR_NOMEM; + char *local_charset = ASPrintf("%s//IGNORE", nsoption_charp(local_charset)); + if(local_charset) { + err = utf8_to_enc(string, local_charset, len, result); + FreeVec(local_charset); + } + return err; } void ami_utf8_free(char *ptr) @@ -44,7 +55,6 @@ void ami_utf8_free(char *ptr) char *ami_utf8_easy(const char *string) { char *localtext; - if(utf8_to_local_encoding(string, strlen(string), &localtext) == NSERROR_OK) { return localtext; } else {