Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows 11 open pdf named in Chinese not working #1470

Open
peter-lyr opened this issue Jun 17, 2024 · 0 comments
Open

windows 11 open pdf named in Chinese not working #1470

peter-lyr opened this issue Jun 17, 2024 · 0 comments

Comments

@peter-lyr
Copy link

in file lua\neorg\modules\core\esupports\hop\module.lua

external_file = function()
                local destination = parsed_link_information.link_location_text
                local path, line = string.match(destination, "^(.*):(%d+)$")
                if line then
                    destination = path
                    line = tonumber(line)
                end
                destination = (
                    vim.tbl_contains({ "/", "~" }, destination:sub(1, 1)) and "" or (vim.fn.expand("%:p:h") .. "/")
                ) .. destination

                return lib.match(vim.fn.fnamemodify(destination, ":e"))({
                    [{ "jpg", "jpeg", "png", "pdf" }] = {
                        type = "external_app",
                        uri = vim.uri_from_fname(vim.fn.expand(destination)), ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
                    },
                    [module.config.public.external_filetypes] = {
                        type = "external_app",
                        uri = vim.uri_from_fname(vim.fn.expand(destination)), ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
                    },
                    _ = function()
                        return {
                            type = "external_file",
                            path = vim.fn.fnamemodify(destination, ":p"),
                            line = line,
                        }
                    end,
                })
            end

in windows11, rundll32.exe url.dll,FileProtocolHandler file:///C:/%e6%96%87%e6%a1%a3.pdf can not open 文档.pdf, but rundll32.exe url.dll,FileProtocolHandler file:///C:/文档.pdf can.

I tried in cmdline with rundll32.exe url.dll,FileProtocolHandler file:///C:/%e6%96%87%e6%a1%a3.pdf, it really not working. but rundll32.exe url.dll,FileProtocolHandler file:///C:/文档.pdf can.

change to this work:

external_file = function()
                local destination = parsed_link_information.link_location_text
                local path, line = string.match(destination, "^(.*):(%d+)$")
                if line then
                    destination = path
                    line = tonumber(line)
                end
                destination = (
                    vim.tbl_contains({ "/", "~" }, destination:sub(1, 1)) and "" or (vim.fn.expand("%:p:h") .. "/")
                ) .. destination

                return lib.match(vim.fn.fnamemodify(destination, ":e"))({
                    [{ "jpg", "jpeg", "png", "pdf" }] = {
                        type = "external_app",
                        uri = vim.fn.expand(destination), ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
                    },
                    [module.config.public.external_filetypes] = {
                        type = "external_app",
                        uri = vim.fn.expand(destination), ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
                    },
                    _ = function()
                        return {
                            type = "external_file",
                            path = vim.fn.fnamemodify(destination, ":p"),
                            line = line,
                        }
                    end,
                })
            end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant