Hướng dẫn lưu file theo định dạng utf-8 java decompiler năm 2024

In Repository API, there are two approaches - String and Stream. One way to change output file's charset is to use Stream approach and configure its paramter as such. For example, if you want to produce a UTF-16 file, you can write Java code as below. For how to use Repository API, see https://support.pega.com/discussion/how-use-repository-api.

java.io.InputStream inputStream = new java.io.ByteArrayInputStream(CSVString.getBytes(java.nio.charset.StandardCharsets.UTF_16)); tools.getStepPage().getProperty("pyStream").setValue(inputStream);

Hướng dẫn lưu file theo định dạng utf-8 java decompiler năm 2024

For Japanese customer, if you want to produce a Shift-JIS file, you can write Java code as below. Instead of using StandardCharsets, specify "MS932" directly. In this case you need a try/catch block or system won't let you save the rule.

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

Closed

Nick-kel opened this issue

Dec 21, 2020

· 18 comments

Assignees

Comments

If I upload something to a language in Weblate, the source language works very well in UTF-8 (e.g. a § is displayed correctly). But if I upload a translation to a "normal" language, it isn't in UTF-8 and in front of a § there's a weird character:

Hướng dẫn lưu file theo định dạng utf-8 java decompiler năm 2024

I'm using the newest version of Weblate

The text was updated successfully, but these errors were encountered:

This issue looks more like a support question than an issue. We strive to answer these reasonably fast, but purchasing the support subscription is not only more responsible and faster for your business but also makes Weblate stronger. In case your question is already answered, making a donation is the right way to say thank you!

Maybe the existing file is iso-8859-1 encoded? What file format do you use? How do you upload?

The existing file is UTF-8 encoded and I'm using a Java Properties (UTF-8) format. I'm uploading the translation using the "Files" > "Upload translation" button in a language.

The upload method is "add as translation"

Can you please share the uploaded file? It seems that it's detected as iso-8859-1 instead of UTF-8. Maybe it has encoding error or there is something wrong with the detection.

There is no unicode char in there which could break...

That one works fine in my tests. The content looks like something (mis-)detectcs it as iso-8859-1. It might be a bug in chardet on the specific file you are using.

I also encountered the same problem. When uploading a new Chinese translation, it will be garbled.

File is UTF-8 encoded.

Hướng dẫn lưu file theo định dạng utf-8 java decompiler năm 2024

@nijel I don't know ... I only uploaded the translations, these are my settings:

Hướng dẫn lưu file theo định dạng utf-8 java decompiler năm 2024
In the source language there's no problem with the encoding, only in other languages

The most likely suspect is still chardet here as the detection is always in place. Unfortunately, the file in doesn't show it. Can reproduce it with that file? Having the actual uploaded file to reproduce this would help...

@GoneTone I can reproduce this if the file format is configured to ISO-8859-1, and it's expected in this case - the replace upload method does no processing of the file. When I switch file format in Weblate to UTF-8, it is shown correctly and the replace upload works fine. What still seems to be broken is regular upload though, what probably matches behavior @Nick-kel was describing initially.