如何使用maven将ascii转换为utf8
我有一些生成的类,它们是使用 ASCII 编码生成的。但要编译此类,这些类必须采用 UTF-8 编码。
所以我需要一个插件来将此类从 ASCII 或 ISO-8859-1 分别转换为 UTF-8。
我尝试使用 maven-resources-plugin 和 native2ascii-maven-plugin 来转换文件。但他们没有我需要的。 maven-resources-plugin 只能配置一个标志,用于读取输入和写入输出。我总是使用UTF-8。所以很明显它没有任何效果。
另一方面,native2ascii-maven-plugin 只会以错误的方向进行转换,即从 UTF-8 转换为 ASCII。但我需要将文件从 ASCII 转换为 UTF8。
还有其他插件或者哪个插件可以解决我的问题吗?我必须使用哪种配置?请提供一个绝对有效的配置片段。
谢谢
I have some generated classes, which are generated with ASCII encoding. But to compile this classes, the classes must be in UTF-8 encoding.
So I need a plugin that converts this classes from ASCII or ISO-8859-1 respectivly to UTF-8.
I tried to use the maven-resources-plugin and the native2ascii-maven-plugin to convert the files. But they didn't what I need.
The maven-resources-plugin can only by configured with one flag, that is used for reading input and writing output. I always use UTF-8. So it's obviously that it hasn't any effect.
On the other hand the native2ascii-maven-plugin only converts in the wrong direction, namly from UTF-8 to ASCII. But I need to convert the files from ASCII to UTF8.
Are there any other plugins or which plugin solves my problem? Which configuration I have to use? Please provide a definitely working configuration snippet.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果一切都失败了,AntRun 插件 和 Ant 的 复制任务及其
encoding
和outputencoding
属性应该做这份工作。If all else fails, the AntRun Plugin and Ant's Copy Task with its
encoding
andoutputencoding
attributes should do the job.ASCII 是 UTF-8 的子集。所有可以用 ASCII 表示的符号都以相同的方式编码为 UTF-8。
(我有一种感觉,你的问题一定太微不足道了,不可能是真的。如果情况实际上更复杂,请编辑你的问题。)
ASCII is a subset of UTF-8. All symbols that can be expressed in ASCII are encoded in the same way in UTF-8.
(I have a feeling that your problem has got to be too trivial to be true. Please edit your question if the case is actually more complex.)