AppleScript tell application “Finder” can’t use special characters

applescriptautomator

I found this question about the possibility to exchange windows paths with mac users and vice versa.

How to translate between Windows and Mac -style file locations?

It's working great for me, but for some reason the finder won't open paths with special characters in it. For example ä, ö, ü (which are common in germany).

I thought they are converted or something. So I removed the tell application part and replaced it with return mylocation to see whats happening. The returned path is the correct one and also special characters are in it.

Why does the finder not open it? Is there any workaround for this?

I paste the code here, so we talk about the same thing without confusion:

on searchReplace(theText, SearchString, ReplaceString)
    set OldDelims to AppleScript's text item delimiters
    set AppleScript's text item delimiters to SearchString
    set newText to text items of theText
    set AppleScript's text item delimiters to ReplaceString
    set newText to newText as text
    set AppleScript's text item delimiters to OldDelims
    return newText
end searchReplace

on run {input, parameters}
    
    set myClip to the input
    set mylocation to searchReplace(myClip, "<", "")
    set mylocation to searchReplace(mylocation, ">.", "")
    set mylocation to searchReplace(mylocation, ">", "")
    set mylocation to searchReplace(mylocation, "\\", "/")
    set mylocation to "smb:" & mylocation
    set mylocation to searchReplace(mylocation, " ", "%20")
    
    
    tell application "Finder"
        open location mylocation
    end tell
    
    # after setting the location, set Finder to topmost, or delete this section if you dont want that.
    tell application "Finder"
        activate
    end tell
    
    
    return input
end run

Best Answer

I fixed it by decoding the umlauts like this:

considering case
    set mylocation to searchReplace(mylocation, "Ä", "%C3%84")
    set mylocation to searchReplace(mylocation, "ä", "%C3%A4")
    set mylocation to searchReplace(mylocation, "Ö", "%C3%96")
    set mylocation to searchReplace(mylocation, "ö", "%C3%B6")
    set mylocation to searchReplace(mylocation, "Ü", "%C3%9C")
    set mylocation to searchReplace(mylocation, "ü", "%C3%BC")
    set mylocation to searchReplace(mylocation, "ß", "%C3%9F")
    set mylocation to searchReplace(mylocation, "ẞ", "%E1%BA%9E")
end considering