Skip to content

Instantly share code, notes, and snippets.

@imax9000
Forked from excavador/escape.go
Last active April 21, 2017 21:37
Show Gist options
  • Save imax9000/759526fe17592555997c60b16c0579c0 to your computer and use it in GitHub Desktop.
Save imax9000/759526fe17592555997c60b16c0579c0 to your computer and use it in GitHub Desktop.
func escapeRune(c rune) rune {
if uint(c) < 0x20 {
return '_'
}
switch c {
case ';', '\n', '"', '\\':
return '_'
default:
return c
}
}
func EscapeFileName(filename string) string {
return strings.Map(escapeRune, filename)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment