encoding problem of output at DiscoveryTest
-
I modified DiscoveryTest.java a little.
That is, instead of System.out.println(pvs); of main() function, I substitued it with
"for (ObjectIdentifier objectIdentifier : oids) {
System.out.println(pvs.getString(objectIdentifier, PropertyIdentifier.description));
}".Of course, I added "refs.add(oid, PropertyIdentifier.description);" at addPropertyReferences() function of the DiscoveryTest.java.
But, the ouput encoding is not right at System.out, so breaked font strings are printed which is originally east asia character.
So I want to know how to change encoding settings of PropertyValues or RequestUtils.readProperties().
Any suggestions are appreciated. -
Hi mirvana,
I am not 100% certain, but I would guess the data type of these properties is a CharacterString? If so it looks like the encoding should be in the received ByteQueue. So, I wonder if there's a setting on the other device?
It doesn't look like there's any way to set a character encoding setting more globally, but maybe I'm missing something. It looks like it prefers ASCII when it is doing something like setting the properties for rendering a BinaryValue, but that other encodings should be supported for reading.
-
Thank you for your answering.
By the way, the return result of PropertyValues.getString() is String, not CharacterString.
And, PropertyValues.getString() use Encodable, internally.
But I got the hint that is changing the return string to CharacterString which has encoding setting, from your help.
I' ll do it first and reply again. -
I'm afraid that the way using CharacterString would be not likely working because I already had used the way of String.getBytes() which is not working and CharacterString.encode() use the way even though I use the function through CharacterString.writeImpl().
I think maybe I have to use the matter about socket, because Bacnet4J use socket network.
Any helps are appreciated. -
I suspect you're right that it's the output stream. I googled for that and found this stack overflow thread, if it's helpful: https://stackoverflow.com/questions/14030811/system-out-character-encoding
-
Thank you.
But the content of the link says it relates java option matter, it seems doubtful a little for me about it.
I'll try it anyway.