Sublime Forum

UnicodeEncodeError View In Browser plugin

#1

I use the sublime portable and after restoring the settings of windows 10 I had a single problem with the View In Browser plugin, in the console the message is displayed

View In Browser plugin v2.0.0, Python 3
Traceback (most recent call last):
File “D:\SublimeText3\sublime_plugin.py”, line 1066, in run_
return self.run(edit, **args)
File “D:\SublimeText3\Data\Installed Packages\View In Browser.sublime-package\ViewInBrowserCommand.py”, line 201, in run
File “D:\SublimeText3\Data\Installed Packages\View In Browser.sublime-package\ViewInBrowserCommand.py”, line 176, in loadPluginSettings
File “D:\SublimeText3\Data\Installed Packages\View In Browser.sublime-package\ViewInBrowserCommand.py”, line 85, in getBaseCommand
File “D:\SublimeText3\Data\Installed Packages\View In Browser.sublime-package\ViewInBrowserCommand.py”, line 67, in expandWindowsUserShellFolder
File “D:\SublimeText3\Data\Installed Packages\View In Browser.sublime-package\ViewInBrowserCommand.py”, line 137, in getWindowsUserShellFolders
UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\xc1’ in position 24: ordinal not in range(128)

Can anyone help me with this problem? I have already uninstalled and reinstalled the View in browser and nothing has returned to normal.

Alternatively, can someone tell me some other method of viewing the file’s content in the browser with a shortcut key?

0 Likes

#2

Encontrei a solução usando a função build do próprio Sublime clicando em

Tools / Build System / New Build System

No arquivo que se abre colocar os comandos

{
        "cmd": ["C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "https://192.168.0.2/$project_base_name/$file_name"]
}

E para colocar a tecla de atalho desejada, abre o Key Bindings

{ "keys": ["f12"], "command": "build" },
0 Likes

#3

Outra solução é criar um New Build System e colocar

“cmd”: [“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”, “https://192.168.0.2/abrir.php?arquivo=$file”]

redirecionando todos os endereços para o arquivo abrir.php do seu servidor local, ficando o código do arquivo abrir.php da seguinte forma

<?php

if (isset($_GET['arquivo'])){
	$url = str_replace("D:\\xampp\\htdocs\\","https://192.168.0.2/",$_GET['arquivo']);
	$url = str_replace("\\","/",$url);
	echo "$url";
	header("Location:$url");
} else {
	echo "Este arquivo é aberto pelo sublime e redireciona para o caminho do servidor correspondente. Não o exclua ";
}

?>
0 Likes