Closed DanielGronau closed 7 years ago
Yes, we very certainly always want to use UTF-8. And your suggested fix looks fine (with java.nio.charset.StandardCharsets.UTF_8
instead of "UTF8"
). do you want to make a PR?
fixed by f775a81516a4640c02817767be9638254d790b88
Under Widows 10, I have the problem that the generated java files have the Windows default encoding, not UTF-8, which garbles the µ identifier in my case.
After trying every way to set an encoding in Maven or my IDE, I assume the annotation processor itself must take care of it. I think the relevant code location is
GenCode:146
:Filer.createSourceFile(genClassName).openWriter()
As far as I understand,
openWriter()
simply wraps the underlying output stream with amOutputStreamWriter
without setting an encoding, which results in using the system default (and not the encoding set forjavac
etc). I haven't tested it, but I would assume that using something likenew OutputStreamWriter(Filer.createSourceFile(genClassName).openOutputStream(), "UTF8")
could probably solve the problem. Of course instead of hard-coding, this could be also a parameter of the annotation processor (although I'm not sure in which scenarios would require another encoding)