Closed tenax66 closed 1 year ago
Hey,
have you tried using https://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/compiler/Environment.html#setEncoding(java.nio.charset.Charset) to set the charset?
Yes, I tried Environment.setEncoding(StandardCharsets.UTF_8)
.
But it only set the encoding of source code that spoon parses, not the output.
Oh, you are correct. It looks like we have no API, or I am not aware of any method for this use case. Your solution might be the correct one.
When processing source code as follows, the character encoding of output files depends on the environment.
For example, when working in Windows (Japanese setting), the encoding of processed source code is CP932, I wanted UTF-8 code though. Is there any simple way to set the encoding of processed source code?
In the case above, I created my own FileGenerator (which outputs files in UTF-8) from
JavaOutputProcessor
and set it toEnvironment
as a work-around. like the following:But I don't think this is a good approach.