Java tutorial
//package com.java2s; public class Main { private static String getAppropriateEncoding(CharSequence contents) { for (int i = 0; i < contents.length(); i++) { if (contents.charAt(i) > 0xFF) { return "UTF-8"; } } return null; } }