javascript go to url with unicode characters

Viewed 696

I have an array with some urls like these:

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

I'm using angular, with ng-repeat I created a clickable list that perform a redirect to desired url, but, when I clicked unicode url, the browser cant find it.

I try with encodeURI("path/url/unicóde"), but it retrieves this: path/url/unic%C3%B3de.txt which is not found. Instead, when I accessing manually to: path/url/unicóde.txt (this is in an ftp, so, I go folder by folder until arrive to the file) the url in the browser now says: path/url/unic%F3de.txt, which is different to value that gave me encodeURI( ).

How then I can clic to this list item and to be redirected to desired unicode url?

Here 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>

javascript:

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

This is an app build with electron + angular, what I want here is that when user clicks the item, open his default browser and redirect it to url

1 Answers
Related