2006-02-17 22:05:10 +01:00
|
|
|
using System;
|
2006-02-19 01:13:39 +01:00
|
|
|
// using System.Collections.Generic;
|
2006-02-17 22:05:10 +01:00
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
namespace Novell.CASA.MiCasa.Common
|
|
|
|
{
|
|
|
|
class Utils
|
|
|
|
{
|
|
|
|
public static string EscapeReservedChars(string origString)
|
|
|
|
{
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
for (int i = 0; i < origString.Length; i++)
|
|
|
|
{
|
|
|
|
switch (origString[i])
|
|
|
|
{
|
|
|
|
case ':':
|
|
|
|
{
|
|
|
|
sb.Append("\\");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case '\\':
|
|
|
|
{
|
|
|
|
sb.Append("\\");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case '=':
|
|
|
|
{
|
|
|
|
sb.Append("\\");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
sb.Append(origString[i]);
|
|
|
|
}
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string UnescapeString(string sOrig)
|
|
|
|
{
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
for (int i = 0; i < sOrig.Length; i++)
|
|
|
|
{
|
|
|
|
if (sOrig[i].Equals('\\'))
|
|
|
|
{
|
|
|
|
if (i + 1 < sOrig.Length)
|
|
|
|
{
|
|
|
|
if (sOrig[i + 1].Equals(':')
|
|
|
|
|| sOrig[i + 1].Equals('\\')
|
|
|
|
|| sOrig[i + 1].Equals('='))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sb.Append(sOrig[i]);
|
|
|
|
}
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|