Skip to content

shell.openExternal(path) does not work well if there are non-ascii chars in the path #6302

Closed

Description

@wangxiexe
  • Electron version:
    1.1.1
  • Operating system:
    win 10

I want to open a dir in local disk on windows, but noticed if there are some chinese chars in the path, it just did not work

you can reproduce it by create a dir named "测试" and try to open that path

( I did not test on newer electron version as I have to stick to electron 1.1.1 for there is a serious bug in later electron version #5844 )

Activity

  1. d3x0r commented on Jul 1, 2016

    @d3x0r

    (for someone who gets around to fixing this)
    From recently fixing my own code around this; you can get the correct 'wide character' command line using GetCommandLineW() and then you can convert that to utf-8 for internal use. (or javascript string or whatever is required) (even if the startup is just a standard WinMain in non _UNICODE mode is being used you can call GetCommandLineW() ); no need to radically change the build.


    Although I was assuming you're opening a file from the command line to launch electron; and it might be that CreateFileW is really where the error is (or wfopen(?) ).

  2. wangxiexe commented on Jul 1, 2016

    @wangxiexe
    Author

    GetCommandLineW seems C/C++ code but I am a javascript guy and no idea what I should do in my code to work around this. please give some some hint what I should do.

    The feature I am implementing is we are going to support downloading some files into a local directory and after the download , I will let my user to open that target directory.

    thx.

  3. zcbenz commented on Jul 1, 2016

    @zcbenz
    Contributor

    If you want to open file you should usually use openItem, which works with Unicode characters.

  4. wangxiexe commented on Jul 3, 2016

    @wangxiexe
    Author

    thx @zcbenz , yes, openItem works. As openExternal works for ascii path, it would be better support for non-ascii as well that way we can only remember one api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions