GithubHelp home page GithubHelp logo

Comments (7)

verhas avatar verhas commented on August 12, 2024

When a license is loaded from an encoded file the byte stream created by the decoding is converted to String using the platform default charset. Probably that is not utf-8 and that is the reason why you get the special characters.

As a side note: the method setLicenseEncodedFromFile is deprecated and will be removed from newer releases, but this has nothing to do with the issue.

I will modify the behaviour to use utf-8 instead of the default charset in the next release, which is not scheduled yet.

from license3j.

rivella50 avatar rivella50 commented on August 12, 2024

So this means at the moment i cannot solve that problem by myself...
Using just UTF-8 probably also is not a good idea.
How about an overloaded License constructor (or the successor of setLicenseEncodedFromFile()) which uses per default the system charset and in a parameterized version the user can define it?

But at first it would be interesting if the problem with the German vowel also happens on your side.

from license3j.

verhas avatar verhas commented on August 12, 2024

If you look at the last commit diff you will see what causes the problem. I temporarily comitted into the source code change that makes the decoding to use utf-8.

The sample you provided and the analysis clearly leads to the conclusion that the default encoding on your machine is iso-latin-1. I see no point to reproduce the issue on my dev machine. And I also do not have the time.

from license3j.

verhas avatar verhas commented on August 12, 2024

I will consider your suggestion extending th API with overloaded methods.

from license3j.

rivella50 avatar rivella50 commented on August 12, 2024

That would be nice, thank you!

from license3j.

qqilihq avatar qqilihq commented on August 12, 2024

I'm experiencing exactly the same issue. (for the records: my system's encoding is UTF-8). The problem is obviously at this point in License:

/**
 * Set the license values from an input stream. The stream has to contain
 * properties.
 *
 * @param is
 *            the input stream to read the properties values from
 * @throws IOException
 *             when the input stream can not be read
 */
public void setLicense(final InputStream is) throws IOException {
	verified = false;
	licenseProperties = new Properties();
	licenseProperties.load(is);
}

java.util.Properties.load(InputStream) will always decode the InputStream using ISO 8859-1 as stated in the JavaDoc. I solved that problem through a quick and dirty fix by overriding the setLicense method as follows and the umlauts decode just fine:

License license = new License() {
	@Override
	public void setLicense(InputStream is) throws IOException {
		// super implementation sets verified = false, but the field
		// cannot be accessed here, however, that doesn't seem to be an
		// issue in my case, as the fields seems to get set correctly
		// through setLicenseEncoded anyways; do not call super, because
		// it will eat up the InputStream
		licenseProperties = new Properties();
		licenseProperties.load(new InputStreamReader(is, "utf-8"));
	}
};

from license3j.

verhas avatar verhas commented on August 12, 2024

new version 1.0.8 will contain the new methods and the old methods are deprecated

from license3j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.