I found urlencode() and urldecode() work nicely, and I particularly like the reversibility, so you can parse the filename to recover the original string.
One caveat : in Windows, * is a reserved character, but Matlab urlencode does not encode that. Although it does decode it. The appears to be the only Windows reserved character that urlencode does not encode. Different languages appear to disagree about whether * should be urlencoded, see https://stackoverflow.com/questions/6533561/urlencode-the-asterisk-star-character/6533607#6533607
So I wrote my own two short functions:
function urlOut = urldecode(urlIn)
urlOut = char(java.net.URLDecoder.decode(urlIn,'UTF-8'));
function urlOut = urlencode(urlIn)
urlIn = replace(urlIn, '*', '%2A');
urlOut = char(java.net.URLEncoder.encode(urlIn,'UTF-8'));