title: How can I convert values stored in ANSI (Windows 1252) in a database to UTF-8
body: <p>When I open a legacy database in Sqlite Browser, the text is already displayed wrong. The only encoding I can set is UTF-8 and UTF-16.<br>
  <a href="https://i.stack.imgur.com/PR9r1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PR9r1.png" alt="Sqlite browser with Umlaut"></a></p>
  
  <p>When I query the database, the encoding is already wrong in Visual Studio.<br>
  <a href="https://i.stack.imgur.com/utIWQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/utIWQ.png" alt="Visual Studio locals"></a></p>
  
  <p>I assume the text is encoded in ANSI (Windows-1252) (<em>confirmed in the comments</em>). I tried converting it to UTF-8</p>
  
  <pre><code>        var encoding = Encoding.GetEncoding(1252);
          byte[] encBytes = encoding.GetBytes(result);
          byte[] utf8Bytes = Encoding.Convert(encoding, Encoding.UTF8, encBytes);
          return Encoding.UTF8.GetString(utf8Bytes);
  </code></pre>
  
  <p>but now the question mark symbol is just a question mark.<br>
  <a href="https://i.stack.imgur.com/R2wzM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R2wzM.png" alt="Still wrong"></a></p>
  
  <p>Somehow, the external legacy app displays it correctly, so there appears to be a way. But I'm not sure what I can try next.</p>