4

I am facing problems when comparing UTF-8 charcters in an Eclipse RCP:

one of my classes generates a string "2 µs", then another class parses this value and checks for "µs". When I launch this RCP directly from eclipse everything works as expected and I am able to parse the value.

But when I build my product using maven, the String I'd like to parse mutates to: "2 µs"

The maven build uses <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>

I checked the class files within my eclipse projects and the jar created by maven: The String constant for "2 µs" uses the same hex encoding: "32 40 C2 B5 73"

There must be some difference between maven compiling my classes and eclipse doing that But I am lost here - does anyone have a solution to this problem?

Christian
  • 446
  • 2
  • 14
  • It looks like [the same problem I was facing](http://stackoverflow.com/questions/11226878/why-do-i-need-to-escape-unicode-in-java-source-files). – Denys Séguret Jul 05 '13 at 09:45
  • It seems to be the same problem, however the solution seems strange to me: eclipse is doing everything right here when launching from within eclipse - so eclipse knows about my file encodings. My build uses maven/tycho and I declared sourceEncodings there, so why does it fail? – Christian Jul 05 '13 at 09:49
  • Eclipse is complex and its always hard to know where it's buggy and where the features are just strange. Here the problem seems to be in Eclipse's Product Export Wizard. – Denys Séguret Jul 05 '13 at 09:50
  • Did you test it ? Did it solve the problem ? – Denys Séguret Jul 05 '13 at 09:51
  • @dystroy: I just tried running my eclipse with -Dfile.encoding=UTF8. It did not solve my problem. As I use maven (embedded, v3.0.4) for my build I am not sure whether this parameter is honored by maven – Christian Jul 05 '13 at 10:53
  • As I don't use maven I can't help you. You might get a better visibility for your question by adding the [java] tag (the [tycho] one might be useless). – Denys Séguret Jul 05 '13 at 10:55
  • Have you tried running maven from the command line (without Eclipse)? If this project is part of a multi-module build, have all the projects been rebuilt and installed to the local artifact repo? – user944849 Jul 09 '13 at 15:11
  • This seems like a bug in Tycho. If you can reproduce this problem in a new, minimal project, it would be good if you could open a bug report in [Tycho's issue tracker](https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Tycho). – oberlies Jan 07 '14 at 13:56

2 Answers2

0

You should configure your Eclipse to make your workspace UTF-8 too, like this UTF-8

after this, your projects will be rebuilded, and this configuration project.build.sourceEncoding will work.

Luiz E.
  • 6,769
  • 10
  • 58
  • 98
0

It may worth checking if your rcp installation workspace.metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.core.resources.prefs has 'encoding=UTF-8'.