code: public static int guessEncodingBitSize(String enc)
      {
          if (enc == null || enc.length() == 0) { // let's assume default is UTF-8...
              return 16;
          }
  
          // Let's see if we can find a normalized name, first:
          enc = CharsetNames.normalize(enc);
  
          // Ok, first, do we have known ones; starting with most common:
          if (enc == CharsetNames.CS_UTF8) {
              return 16; // meaning up to 2^16 can be represented natively
          } else if (enc == CharsetNames.CS_ISO_LATIN1) {
              return 8;
          } else if (enc == CharsetNames.CS_US_ASCII) {
              return 7;
          } else if (enc == CharsetNames.CS_UTF16
                     || enc == CharsetNames.CS_UTF16BE
                     || enc == CharsetNames.CS_UTF16LE
                     || enc == CharsetNames.CS_UTF32BE
                     || enc == CharsetNames.CS_UTF32LE) {
              return 16;
          }
  
          /* Above and beyond well-recognized names, it might still be
           * good to have more heuristics for as-of-yet unhandled cases...
           * But, it's probably easier to only assume 8-bit clean (could
           * even make it just 7, let's see how this works out)
           */
          return 8;
      }
docs: Method used to figure out which part of the Unicode char set the
  encoding can natively support. Values returned are 7, 8 and 16,
  to indicate (respectively) "ascii", "ISO-Latin" and "native Unicode".
  These just best guesses, but should work ok for the most common
  encodings.