Search This Blog

Breaking

Sunday, 31 October 2021

[Fix] [Windows]Text is coming in incorrect encoding in Jenkin and in local machine

 Recent ally, I encountered one issue where one of the multilingual texts








was coming differently in my local environment(IDE). It was a pretty annoying issue because the string was coming with special characters when I was running my program, while when I tried to replicate it in a different project, the same was working fine.

I posted the question in StackOverflow too but could not find a better solution for it.

To fix this issue, I used apache common lang3 Stringutil escape until method. This method converted the special characters to HTML. Now, I thought to put a regex to remove the HTML. But with my bad, it didn't work.

So, after spending a lot of time, I figured that this is happening because of encoding. So I checked my file encoding.

In Intelij, we can check encoding by: ctril+shift+d -> Editor->File Encoding.

There I found that the file encoding was set as "Windows 1252". 

I changed it to UTF-8. Later, I change all individual file encoding also to UTF-8.

This fixed the issue in my local machine.

The same issue when I got in Jenkin machine, I fixed the encoding from the pom.xml file.

Here is my question from StackOverflow.

 

No comments:

Post a Comment