unmappable character for encoding UTF-8

“Encoding” is one of the most headache problem in a webapp. It alway goes with these kinds of files: java, javascript. And the cause is widely related to our system encoding, file encoding, idea encoding( development tool encoding, project encoding, javac encoding).

Initial file encoding:
Each file will get an encoding at its creation. This encoding is decided by the develpment tool. It always be one of UTF-8, GBK and ISO-8859.

garbled with javascript files
garbled: Some of your javascript files’ encoding is different with the project encoding that specified in idea [file encoding–>project encoding].
solve Change the [file encoding–>project encoding] same with the javascript files’ encoding.

console garbled
solve: [settings–>…–>maven–runner]jvm options: -Dfile.encoding=UTF-8

compile error with java files
example: unmappable character for encoding UTF-8.
error: Some of your java files’ encoding is different with javac encoding, it will goes with a compile error.
cause: The javac use an encoding to encode characters in java files when compileing them. The encoding is always the system encoding. But we can specify it at any where that will use javac, like maven plugin and tomcat plugin in idea. And we can also specify it at poms.
solve: When the error occured, find the file in idea and convert its encoding to the target encoding. You can also javac encoding. The rule is to ensure the two encodings same.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值