Textmate does not allow open a file with characters in unknown encoding. For example, when a wrong encoding is selected, the Open button is disabled:

When a proper encoding is selected, the Open button is enabled:

Is there a c or Objective-C library for reporting characters encoded outside current encoding?