title: .NET for Windows Store Apps: UrlEncode
body: <p>In some Windows Store App I need send URL like  </p>
  
  <pre><code>new Uri(string.Format(@"http://www.site.com?word={0}",
                                        sourceText))
  </code></pre>
  
  <p>, where <code>sourceText</code> is the escaped representation of some text. It would be easy, if I need UTF-8, but I need Windows-1251 encoding.</p>
  
  <p>I have tried</p>
  
  <pre><code>    byte[] unicodeBytes = Encoding.Unicode.GetBytes(sourceText);
      byte[] win1251bytes = Encoding.Convert(Encoding.Unicode, Encoding.GetEncoding("windows-1251"), unicodeBytes);
      string sourceText =
          Uri.EscapeUriString(Encoding.GetEncoding("windows-1251").GetString(win1251bytes, 0, win1251bytes.Length));
  </code></pre>
  
  <p>but <code>Uri.EscapeUriString</code> use <code>string</code>, which converting to Unicode automatically.</p>
  
  <p>I could use <code>HttpUtility.UrlEncode(word, Encoding.GetEncoding(1251)</code>, but there is no <code>System.Web.HttpUtility</code> in .NET for Windows Store.</p>
  
  <p>For example, 'привет' in UTF-8: <code>%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82</code>;
                       in Windows-1251 : <code>%EF%F0%E8%E2%E5%F2</code>.  I need second string</p>