diff --git a/Assets/Cryville/Common/StringUtils.cs b/Assets/Cryville/Common/StringUtils.cs index a25dc67..b230bc8 100644 --- a/Assets/Cryville/Common/StringUtils.cs +++ b/Assets/Cryville/Common/StringUtils.cs @@ -1,5 +1,6 @@ using System; using System.Text; +using System.Text.RegularExpressions; namespace Cryville.Common { /// @@ -33,5 +34,13 @@ namespace Cryville.Common { b.Append((timeSpan.TotalSeconds % 60).ToString("00." + new string('0', digits))); return b.ToString(); } + /// + /// Escapes special characters in a file name. + /// + /// The file name excluding the extension. + /// The escaped file name. + public static string EscapeFileName(string name) { + return Regex.Replace(name, @"[\/\\\<\>\:\x22\|\?\*\p{Cc}\.\s]", "_"); + } } }