CSharp examples for System:String Encode Decode
Encode Vbs
/***************************************************************** * Copyright (C) 2005-2006 Newegg Corporation * All rights reserved./*ww w .j a v a 2s . co m*/ * * Author: Jason Huang (jaosn.j.huang@newegg.com) * Create Date: 07/02/2008 15:12:41 * Usage: * * RevisionHistory * Date Author Description * *****************************************************************/ using System.Text; public class Main{ private static string EncodeVbs(string strInput) { if (strInput == null) { return null; } if (strInput.Length == 0) { return "\"\""; } StringBuilder builder = new StringBuilder("", strInput.Length * 2); bool flag = false; foreach (char ch in strInput) { if ((((ch > '`') && (ch < '{')) || ((ch > '@') && (ch < '['))) || (((ch == ' ') || ((ch > '/') && (ch < ':'))) || (((ch == '.') || (ch == ',')) || ((ch == '-') || (ch == '_'))))) { if (!flag) { builder.Append("&\""); flag = true; } builder.Append(ch); } else { if (flag) { builder.Append("\""); flag = false; } builder.Append("&chrw(" + ((uint)ch).ToString() + ")"); } } if ((builder.Length > 0) && (builder[0] == '&')) { builder.Remove(0, 1); } if (builder.Length == 0) { builder.Insert(0, "\"\""); } if (flag) { builder.Append("\""); } return builder.ToString(); } }