private static String ValidateCharset(String cs) { if (cs == null || cs.Length == 0) { return(null); } cs = iText.IO.Util.StringUtil.ReplaceAll(cs.Trim(), "[\"']", ""); if (PortUtil.CharsetIsSupported(cs)) { return(cs); } StringBuilder upperCase = new StringBuilder(); for (int i = 0; i < cs.Length; i++) { upperCase.Append(char.ToUpper(cs[i])); } cs = upperCase.ToString(); if (PortUtil.CharsetIsSupported(cs)) { return(cs); } // if our this charset matching fails.... we just take the default return(null); }