In my project, we have some Chinese comments in routes. But when we try to compile the source code, Play throws the following errors
[error] IO error while decoding Routes.scala with UTF-8
[error] Please try specifying another one using the -encoding option
[error] one error found
[error] (demo/compile:compileIncremental) Compilation failed
[error] Total time: 4 s, completed 2016-5-11 11:00:05
test routes is
#优惠包编辑
GET /coupon/promotionCode/edit/:id coupon.PromotionCodeApplication.edit(id:String)
after compile, the Routes.scala
"GET",
"""@(优惠管理,优包惠编�?, coupon.group.edit)""",
this.prefix + """coupon/group/edit/""" + "$" + """id<[^/]+>"""
Hi @evandu,
Is the routes file encoded as UTF-8? If so, can you provide a small sample project showing the error?
@evandu I think I know what the problem is. The routes compiler is using the default system encoding, which is what the JVM uses, but you are explicitly setting UTF-8 for just the scala compiler. What you can do is set the environment variable:
JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
That will tell Java to use UTF-8 as the default encoding in the JVM.
I'm not sure this is something we can/should fix in Play. Unfortunately the scala compiler and java have two different ways of setting the encoding, and you have to make sure those are consistent.
Thanks a lot
Most helpful comment
@evandu I think I know what the problem is. The routes compiler is using the default system encoding, which is what the JVM uses, but you are explicitly setting UTF-8 for just the scala compiler. What you can do is set the environment variable:
That will tell Java to use UTF-8 as the default encoding in the JVM.
I'm not sure this is something we can/should fix in Play. Unfortunately the scala compiler and java have two different ways of setting the encoding, and you have to make sure those are consistent.