locked
CreateProcess errors with Japanese Characters RRS feed

  • Question

  • Hi,

    I use a Unicode enabled VC++ project that will do that will parse a text file containing some inputs and then create a command using those inputs and invoke the CreateProcess to create the process.

    In my particular case, I have some japanese characters in the text file. These are being perfectly read and passed on to the commandline parameter of the CreateProcess. Also note that I am working on an English windows XP machine.

    However, when the CreateProcess creates the process, the japanese characters are being converted to question marks and as a result of which the process is not created properly.

    Please let us know how this problem can be solved.

    Intended Installation Commandline (parsed correctly):

    "D:\WorkSpace_Iberia\tools\windows\jdk\jdk1.7.0\bin\java.exe" -Xms16777216 -Xmx50331648 -classpath "C:\Program Files\A바탕\_mm_installation\;C:\Program Files\A바탕\_mm_installation\uninstallerResources.zip;" com.zerog.lax.LAX

    The command line actually taken by the create process

    "D:\WorkSpace_Iberia\tools\windows\jdk\jdk1.7.0\bin\java.exe" -Xms16777216 -Xmx50331648 -classpath "C:\Program Files\A??\_mm_installation\;C:\Program Files\A??\_mm_installation\uninstallerResources.zip;" com.zerog.lax.LAX

    Note: Here the Folder with name as A바탕 is getting converted to A?? resulting in the CreateProcess failure.

    Thanks in advance.

    Thanks

    Jiju

    Wednesday, March 14, 2012 12:24 PM

Answers

  • Hi Jiju,

    To fix this issue, I suggest you check the format of the text file. We should make sure that it is encoding with Unicode. If not so, the Japanese characters will be question marks. You can try Save As option and choose Unicode at the bottom of the dialog to keep Unicode encoding. And then check the character set of the project. We should make sure that it is Use Unicode Character Set option for property page->Configuration Properties->General->Character Set.

    I hope this reply is helpful to you. If you have any questions, please feel free to let me know.
    Best regards,


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Helen Zhao Wednesday, March 21, 2012 7:30 AM
    Friday, March 16, 2012 5:36 AM

All replies

  • How sure are you that the argument values as received by java.exe are corrupted?  Could the ?? characters be due to the way something is reporting the values?

    Although you probably don't have a debug version of java.exe which you can use to check, you can create a debuggable test console executable which you can execute instead of java.exe.  It doesn't have to do anything fancy - just allow you to put a breakpoint on its main() function so that you can inspect the argv values passed to it.


    Answering policy: see profile.

    Wednesday, March 14, 2012 12:42 PM
  • Hi,

    Thanks for your reply David.

    I inspected the values before the actual call and the unicode characters were proper. 

    I will try this debug version of a simple console executable and see if it helps.

    Thanks,

    Jiju

    Wednesday, March 14, 2012 1:01 PM
  • Hi Jiju,

    To fix this issue, I suggest you check the format of the text file. We should make sure that it is encoding with Unicode. If not so, the Japanese characters will be question marks. You can try Save As option and choose Unicode at the bottom of the dialog to keep Unicode encoding. And then check the character set of the project. We should make sure that it is Use Unicode Character Set option for property page->Configuration Properties->General->Character Set.

    I hope this reply is helpful to you. If you have any questions, please feel free to let me know.
    Best regards,


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Helen Zhao Wednesday, March 21, 2012 7:30 AM
    Friday, March 16, 2012 5:36 AM
  • Try using -Dsun.jnu.encoding=UTF-8 flag as suggested on http://happygiraffe.net/blog/2009/09/24/java-platform-encoding/ and encode all your command line parameters in UTF-8, then pass them as UTF-16 string, i.e. for each UTF-8 byte you should add zero byte right after it. Use WideCharToMultibyte(CP_UTF8) and then MultibyteToWideChar(CP_ACP), then pass the string you'll get as a command line parameter. For example, if system locale is English (US) and default codepage is windows-1252, then you should pass something like this to your CreateProcess function:

    "D:\WorkSpace_Iberia\tools\windows\jdk\jdk1.7.0\bin\java.exe" -Xms16777216 -Xmx50331648 -classpath "C:\Program Files\A바탕\_mm_installation\;C:\Program Files\A바탕\_mm_installation\uninstallerResources.zip;" com.zerog.lax.LAX

    Tuesday, August 18, 2015 6:14 PM