From 0252dc806646afc949b7f3822899c6b72c8c5dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Thu, 17 Oct 2024 22:10:12 -0300 Subject: [PATCH] Remove funny characters fix. Encode with UTF8 by default. --- .../com/genexus/internet/HttpClientJavaLib.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java b/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java index 662d47cb0..895931ccc 100644 --- a/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java +++ b/java/src/main/java/com/genexus/internet/HttpClientJavaLib.java @@ -725,14 +725,17 @@ 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); - if (res.matches(".*[Ã-ÿ].*")) { - res = EntityUtils.toString(entity, StandardCharsets.UTF_8); - } eof = true; return res; } catch (IOException e) {