smilax:: Notes | [Changes] [Calendar] [Search] [Index] [PhotoTags] |
[Bedstraw] *smilax* |
internal static string CleanFileName( string s ) { System.Text.StringBuilder z= new System.Text.StringBuilder(); foreach (char c in s) { if (System.Char.IsLetterOrDigit(c)) { z.Append(System.Char.ToLower(c)); } else { //z.Append('%'); z.AppendFormat("%{0:X2}", (int)c); } } return z.ToString(); } #if DEBUG [TestFixture] public class PersonChatModelTests { [Test] public void TestCleanFileName_ToLower() { NUnit.Framework.Assert.AreEqual( "message2earth", PersonChatModel.CleanFileName("Message2Earth") ); } [Test] public void TestCleanFileName_HexEscapes() { NUnit.Framework.Assert.AreEqual( "earth%20people%21joe%40milky%2Dway%2Egal", PersonChatModel.CleanFileName("earth people!joe@milky-way.GAL") ); } } #endif
(last modified 2006-04-18) [Login] |