|
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
namespace J2i.Net.FindMe
{
public class Utility
{
public static string ExtractPhoneNumber(String source)
{
StringBuilder retVal = new StringBuilder();
for(int i=0;i<source.Length;++i)
if(Char.IsDigit(source[i]))
retVal.Append(source[i]);
if ((retVal.Length > 0) && (retVal[0] == '1'))
retVal.Remove(0, 1);
return retVal.ToString();
}
public static string UrlEncode(string source)
{
StringBuilder sb = new StringBuilder();
ASCIIEncoding enc = new ASCIIEncoding();
byte[] bSource = (new ASCIIEncoding()).GetBytes(source);
for (int i = 0; i < bSource.Length; ++i)
{
char c = Convert.ToChar( bSource[i]);
if (Char.IsLetterOrDigit(c))
sb.Append(c);
else
{
sb.Append("%");
sb.Append(bSource[i].ToString("X"));
}
}
return sb.ToString();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.