System.Globalization.Bootstring.Decode C# (CSharp) Method

Decode() public method

public Decode ( string s, int offset ) : string
s string
offset int
return string
		public string Decode (string s, int offset)
		{
			int n = initial_n;
			int i = 0;
			int bias = initial_bias;
			int b = 0;
			StringBuilder sb = new StringBuilder ();

			for (int j = 0; j < s.Length; j++) {
				if (s [j] == delimiter)
					b = j;
			}
			if (b < 0)
				return s;
			sb.Append (s, 0, b);

			for (int z = b > 0 ? b + 1 : 0; z < s.Length; ) {
				int old_i = i;
				int w = 1;
				for (int k = base_num; ; k += base_num) {
					int digit = DecodeDigit (s [z++]);
					i = i + digit * w;
					int t = k <= bias + tmin ? tmin :
						k >= bias + tmax ? tmax :
						k - bias;
					if (digit < t)
						break;
					w = w * (base_num - t);
				}
				bias = Adapt (i - old_i, sb.Length + 1, old_i == 0);
				n = n + i / (sb.Length + 1);
				i = i % (sb.Length + 1);
				if (n < '\x80')
					throw new ArgumentException (String.Format ("Invalid Bootstring decode result, at {0}", offset + z));
				sb.Insert (i, (char) n);
				i++;
			}

			return sb.ToString ();
		}
	}