1

I have an eclipse based application. I want to set name for an object in German locale. If I use Java it is working fine. But in c++, if i hard code a string with German characters, the German characters displayed as question mark.

I am using visual studio for c++. Whether am missing any compiler configuration?

Eli Sadoff
  • 7,173
  • 6
  • 33
  • 61
ansariBE
  • 45
  • 6
  • 2
    We'd probably need to see what you actually did to figure out what you may have done wrong. – Galik Oct 30 '16 at 01:58
  • http://stackoverflow.com/questions/3011082/c-stdstring-and-utf-8 Read here I think it will help you – TheOwl Oct 30 '16 at 08:08
  • 1
    Are you using a narrow string literal or a wide string literal? What encoding is the source file saved in? What version of C++ are you using? How are you displaying the characters? There are many factors at play here that could be causing your issue, but your question is too broad. Narrow it down, and provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve), or your question is likely to get closed as off-topic – Remy Lebeau Oct 30 '16 at 08:08
  • Using narrow string literal. Displaying not in the console. Am not sure about the encoding. Will visual studio saves in utf8 by default? – ansariBE Oct 30 '16 at 08:12
  • How are you intending to use C++ in an Eclipse plugin which must be written in Java? – greg-449 Oct 30 '16 at 08:13
  • @greg, Wil call c++ source code inside the java code. – ansariBE Oct 30 '16 at 08:15
  • Which means you are going to have to write JNI code to interface from Java to C++ and mess around with Bundle-NativeCode to tell the plugin where the dll/so/jnilib is. You will also need to do a different version of the plugin for each platform you support. – greg-449 Oct 30 '16 at 08:47
  • What's your file encoding ? VS 2015 needs to know that your file is UTF8 so you need to save it with UTF8 BOM. Another option is to use UTF8 hexadecimal code in your string. – Bertrand Oct 30 '16 at 17:13
  • Am using vs2012. How to save it in utf8 format. I know how to do it in notepad. – ansariBE Oct 30 '16 at 18:08
  • If i use hexadecimal format, will it work in all OS 32 and 64 bits?? Am also in doubt that, I have to write only code. I wont build the project. If I save a file in utf8 in VS, the encoding remains same if someone opens the file in a different machine? – ansariBE Oct 30 '16 at 18:11

0 Answers0