From 4f92ac896d007cb5a7ba9c20489f21c9cca37d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:56:42 +0900 Subject: [PATCH] Encode using UTF-8 if return has funny characters (#904) * Encode using UTF-8 if return has funny characters Issue:201744 * Remove funny characters fix. Encode with UTF8 by default. --- .../java/com/genexus/internet/HttpClientJavaLib.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java b/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java index a3fd0de21..895931ccc 100644 --- a/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java +++ b/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java @@ -725,9 +725,15 @@ public String getString() { return ""; try { this.setEntity(); - Charset charset = ContentType.getOrDefault(entity).getCharset(); - if (charset == null) { + ContentType contentType = ContentType.getOrDefault(entity); + Charset charset; + if (contentType.equals(ContentType.DEFAULT_TEXT)) { charset = StandardCharsets.UTF_8; + } else { + charset = contentType.getCharset(); + if (charset == null) { + charset = StandardCharsets.UTF_8; + } } String res = EntityUtils.toString(entity, charset); eof = true;