问题
I get the error below with an Ant skript I wrote.
I already did some googling and found out, that the problem lies with strings containing \u, which happens under Windows because of the directory separator. I changed all those to / but the error remains.
There are definitely no remaining \u strings in my script.
java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
The error occurs when executing the propertyfile task, so I examined the file I want to change. This on the other hand contains multiple \u strings. The file has no relation to ant though, it's a borland project file (xml) which contains one line like [someParameter]=[someValue].
I just want to increase [someValue] by 1.
So my question is:
Can the property file I want to change cause the error mentioned
and if the answer is "yes",
What can I do, other than doing it with a regex task (like finding the line, propertyregex-ing the value, math+1 the value and regex-replacing the value)
回答1:
i know that this question was asked a while ago but i stumbled on it without an answer, on another site i found (http://www.coderanch.com/t/107014/tools/Malformed-uxxxx-encoding-error) i found that this could happen when instead of "\" for file destinations you should be using "/" because of how parsing works/ Hope this helps.
回答2:
Use the double backslash ("\\") like "abc\\user" which is equivalent to "abc\user" and will solve the issue.
回答3:
first you should try running the ant script with the debug flag to determine which file is causing the issue in Eclipse you do this by going to
Run > External Tools > External Tools Configurations... > Main
and adding "-d" (without the quotes) to "Arguments"
then try editing the file in Eclipse as some editors (e.g. "Wordpad") may mess up the file
回答4:
Actually I found out that the problem is due to the local.cfg file encoding. If we created(edited) the local.cfg file using wordpad or other non code editing software, it changes the file encoding. So when ant tries to load the local configuration file ( due to the line in the dspace-installer/ build.xml file, it expects ASCII character encoded, .cfg file. So when it gets the UTF encoded file the exception raises. Solution: remove the local.cfg file, create it again using a code editing softwares like Visual Studio code or other, and edit/write the necessary configuration settings.
来源:https://stackoverflow.com/questions/17043037/ant-malformed-uxxxx-encoding-in-propertyfile-task