Detecting Encoding in C#

On a project that I’ve been working on recently, I was having some trouble combining SQL scripts that where in a couple of different formats.

While there’s no easy way to detect all of the possible encodings, by checking the byte order mark (BOM) there is a pretty straight forward way to detect the following encodings:

  • UTF-16
  • UTF-16BE
  • UTF-32
  • UTF-32BE
  • UTF-8

2 Responses to “ “Detecting Encoding in C#”

  1. Mike says:

    Thanks, really helpful

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>