-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solve the problem of garbled characters #271
Conversation
…d packages and garbled characters
https://stackoverflow.com/questions/51066207/utf-8-characters-not-displaying-correctly-in-inno-setup |
@@ -47,7 +45,7 @@ public static ExecutionResult executeWithResult(File workingDirectory, String ex | |||
|
|||
Process process = command.execute(); | |||
|
|||
BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream())); | |||
BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream(), Charset.forName("GBK"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is GBK for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this won't present other problems with other language encodings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure.
maybe so:
BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream(), CharSetUtil.getCommandLineChartSet()));
public class CharSetUtil {
public static Charset getCommandLineChartSet(){
try{
Process p = Runtime.getRuntime().exec("cmd /k chcp");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String res = br.readLine();
String code = find("\\d+",res);
switch (code){
case "936": return Charset.forName("GBK");
case "65001": return Charset.forName("UTF-8");
}
}catch (Exception e){
}
return return Charset.defaultCharset();
}
private static String find(String pattern,String data){
Pattern r = Pattern.compile(pattern);
Matcher matcher = r.matcher(data);
matcher.find();
return matcher.group();
}
}
https://learn.microsoft.com/en-us/windows/win32/intl/code-page-bitfields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fvarrui
Do you have any questions?
Hi @lhDream! |
Please, take a look at this: JavaPackager/src/main/java/io/github/fvarrui/javapackager/utils/VelocityUtils.java Lines 65 to 76 in 49528dc
I reverted your changes in this part of the code, but keeping the possibility to render files with Velocity including the BOM ... We should only include the BOM in those files where it is essential, not in all files by default. Do you know which files really need it? |
Hi @fvarrui
|
Ok, done! JavaPackager/src/main/java/io/github/fvarrui/javapackager/packagers/GenerateSetup.java Lines 57 to 59 in 60bd8cb
JavaPackager/src/main/java/io/github/fvarrui/javapackager/utils/VelocityUtils.java Lines 69 to 77 in 60bd8cb
Could you test branch |
Hi @fvarrui
|
Yes, sorry, I mean 271 🙄 |
@fvarrui |
Merged into |
FYI: This change breaks with the non-unicode InnoSetup 5.x version... it cant read the iss file. This IS version is old, but this could be added to the documentation. (use 6.x or 5.x Unicode) |
Solve the problem that CJK characters cannot be packaged and installed packages and garbled characters. #202