2

I have a Java application in which I wish to call to another C++ application. For that, in my Java I call

Runtime.exec(args)

My arg is "HelloWorldèçàœ".

When my C++ recives this arg, it sees it as "HelloWorld????". I looked in memory map and the characters èçàœ appear as 3f 3f 3f 3f.

( In addition, I am not sure that this is relevant, but when I compiled my C++, I have chosen the option: "Character Set = Use Multi-Byte Character Set" (in Properties->General). )

Q: How can I pass such a param from Java to C++?

Thanks

Yura
  • 2,381
  • 8
  • 33
  • 44
  • I just created a simple Java app (compiled on Windows with Sun's Java compiler) that calls a simple C++ app (compiled with Microsoft Visual C++ 2010) and wasn't able to reproduce this problem. Would you be able to provide the exact code that you're using, as well as info about your environment, compilers, etc.? Character encoding issues tend to be extremely subtle and depend on things that you would never think are relevant (for example, if you put the string "HelloWorldèçàœ" as a literal in the Java source file, the encoding of the Java source file can be the culprit). – chess007 Nov 25 '11 at 16:38

1 Answers1

0

It's probably because of the encodings you're using on both sides. Try to ensure that your "args" is stored as the UTF-8 string in Java, and try to read is as UTF-8 string in your C++ code.

Othewise Java uses platform's default encoding, which may be not even supporting these "èçàœ" characters.

axsm
  • 36
  • 1