Javascript go to url with unicode characters

I have an array with URLs like these:

[ "path/to/url1", "path/to/url2", "path/url/unicóde.txt" ] 

I use angular, with ng-repeat . I created a clickable list that redirects to the desired URL, but when I clicked the Unicode URL, the browser could not find it.

I'm trying to use encodeURI("path/url/unicóde") , but it removes it: path/url/unic%C3%B3de.txt , which can not be found. Instead, when I get access manually: path/url/unicóde.txt (this is ftp, so I go to the folder until you come to a file) in the url in the browser is now said: path/url/unic%F3de.txt that differs from the value, which gave me encodeURI( ) .

How can I click this list item and redirect to the desired Unicode URL?

Here's the code: HTML:

 <md-list-item ng-repeat="found in foundFiles"> <h3>{{ found.name }}</h3> <p ng-click="openFtpLink(found.url)">{{ found.url}}</p> </md-list-item> (found.url)"> {{found.url}} </ p> <md-list-item ng-repeat="found in foundFiles"> <h3>{{ found.name }}</h3> <p ng-click="openFtpLink(found.url)">{{ found.url}}</p> </md-list-item> 

JavaScript:

 $scope.foundFiles = [...] $scope.openFtpLink = function (ftpLink) { var spawn = require('child_process').spawn; spawn('cmd.exe', ['/c', 'start', '', ftpLink]); }; ) spawn.; $scope.foundFiles = [...] $scope.openFtpLink = function (ftpLink) { var spawn = require('child_process').spawn; spawn('cmd.exe', ['/c', 'start', '', ftpLink]); }; 

This is the assembly of applications using electron + angular, what I want here is that when the user clicks on an element, open its default browser and redirect it to the URL

+6
source share
1 answer

Use the JavaScript function escape() . He gives the desired result.

 alert(escape("path/url/unicóde.txt")); 
Run codeHide result

Note. The function escape() is deprecated in JavaScript 1.5.

0
source

All Articles