Remove all non-ascii symbols from path during import, because FFXIV can not handle them correctly.

This commit is contained in:
Ottermandias 2021-06-03 15:26:30 +02:00
parent 04c42b7842
commit 6012b2c6ea
2 changed files with 21 additions and 1 deletions

View file

@ -190,7 +190,7 @@ namespace Penumbra.Importer
private DirectoryInfo CreateModFolder( string modListName )
{
var correctedPath = Path.Combine( _outDirectory.FullName,
Path.GetFileName( modListName ).RemoveInvalidPathSymbols() );
Path.GetFileName( modListName ).RemoveInvalidPathSymbols().RemoveNonAsciiSymbols() );
var newModFolder = new DirectoryInfo( correctedPath );
var i = 2;
while( newModFolder.Exists && i < 12 )

View file

@ -1,4 +1,6 @@
using System.IO;
using System.Linq;
using System.Text;
namespace Penumbra
{
@ -11,5 +13,23 @@ namespace Penumbra
public static string RemoveInvalidPathSymbols( this string s )
=> string.Concat( s.Split( _invalid ) );
public static string RemoveNonAsciiSymbols( this string s, string replacement = "_" )
{
StringBuilder sb = new( s.Length );
foreach( var c in s )
{
if( c < 128 )
{
sb.Append( c );
}
else
{
sb.Append( replacement );
}
}
return sb.ToString();
}
}
}