Skip to content

Commit

Permalink
Remove funny characters fix. Encode with UTF8 by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-sexenian committed Oct 18, 2024
1 parent ee5b813 commit 0252dc8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions java/src/main/java/com/genexus/internet/HttpClientJavaLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0252dc8

Please sign in to comment.