How to replace backslahes in accented String

I need to replace all the backslashes in the list of files url.
The problem is that:

  1. The URLs contain accented letters
  2. The URLs were copied relatively to the connected network disk and I
    need to replace it with a real url.

For example, I have this:

Q:\Mes Clients\BUT_Monétique et Commerçant\IG30_Suivi_Projet

and I should replace it with the following:

\\someNetHD\Folder\Mes Clients\BUT_Monétique et
Commerçant\IG30_Suivi_Projet

So I need prefix the common url with th real network address and either
replace all the backslashes with forward ones or with double backslahes.

I tried

path.gsub!("\", “/”)

but it didn’t work. Any idea? Thank you.

Hi,

What exactly happens? It does work for me:

path = ‘Q:\Mes Clients\BUT_Monétique et Commerçant\IG30_Suivi_Projet’
path.gsub! “\”, “/”
puts path # outputs the path with all backslashes replaced

Works for me.

[4] pry(main)> path = ‘Q:\Mes Clients\BUT_Monétique et
Commerçant\IG30_Suivi_Projet’
=> “Q:\Mes Clients\BUT_Monétique et Commerçant\IG30_Suivi_Projet”
[5] pry(main)> path.gsub! “\”, “/”
=> “Q:/Mes Clients/BUT_Monétique et Commerçant/IG30_Suivi_Projet”