62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using System;
|
|
// using System.Collections.Generic;
|
|
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();
|
|
}
|
|
}
|
|
}
|