Archived

This forum has been archived. Please start a new discussion on GitHub.

InitializationData no Support Chinese Path

InitializationData no Support Chinese Path

Ice::InitializationData initData;
initData.properties = Ice::createProperties();

initData.properties->load("C:\\中国\config.client");

Throw const IceUtil::Exception

Comments

  • bernard
    bernard Jupiter, FL
    Hello,

    Welcome to our forums!

    Please always include the Ice version, compiler version and operating system you're using when reporting an issue.

    Assuming you're using the latest version of Ice (3.4.1), you should be able load your config file from a directory with non-ASCII characters.

    You also have to be careful. One question which encoding you use for these narrow string literals; by default, Ice expects all narrow strings to be UTF-8.

    This discussion on Stack Overflow suggests you're better off using only ASCII characters in narrow string literals.

    Could you update your code and try the following:
    // UTF-16; also note the double \ before config.client
    wstring configFile = L"C:\\中国\\config.client"; 
    
    initData.properties->load(IceUtil::wstringToString(configFile));
    

    Then, in case you still get an exception, you should catch and "print" this exception to get more details about the problem:
    try
    {
       ...
    }
    catch(const IceUtil::Exception& e)
    {
          cerr << "Caught: " << e << endl;
    }
    

    Best regards,
    Bernard
  • bernard
    bernard Jupiter, FL
    For my suggested code to work properly with Visual Studio:
    wstring configFile = L"C:\\&#20013;&#22269;\\config.client"; 
    

    You also need to save your source file with the proper encoding. In Visual Studio, goto File > Advanced Save Options... and select "Unicode (UTF-8 with signature) - Codepage 65001" as your Encoding.

    Best regards,
    Bernard