I have file names that contain the substrings% uXXXX, where XXXX are hexadecimal numbers / digits, e.g.% u0151, etc. I got these file names using URI.unescape, which was able to replace the substrings% XX with the corresponding characters, but the% uXXXX substrings remained untouched. I would like to replace them with the corresponding Unicode codes using String # gsub. I tried the following but did not succeed:
"rep%u00fcl%u0151".gsub(/%u([0-9a-fA-F]{4,4})/,'\u\1')
I get this:
"rep\\u00fcl\\u0151"
Instead of this:
"repülő"
source
share