/* * [Encodings.java] * * Summary: Display which encodings are supported on your machine. * * Copyright: (c) 1996-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.1 1996-01-01 add application test harness. ANT builds * 1.2 1996-01-01 displays the name and canonical name of the default * encoding. unfortunately, this means it must be signed. * 1.3 2006-03-03 soldiers on if not granted permission. * 1.4 2006-03-05 reformat with IntelliJ, add Javadoc. * 1.5 2006-03-07 convert to Swing, use layout, allow to run as Hybrid. * 1.6 2007-05-16 convert to JDK 1.5, add PAD, add icon. * 1.7 2014-12-02 add count of encoding */ package com.mindprod.encodings; import com.mindprod.common18.Common18; import com.mindprod.common18.HybridJ; import com.mindprod.common18.VersionCheck; import com.mindprod.fastcat.FastCat; import javax.swing.JApplet; import javax.swing.JScrollPane; import javax.swing.JTextArea; import java.awt.Insets; import java.nio.charset.Charset; import java.security.AccessControlException; import java.util.SortedMap; /** * Display which encodings are supported on your machine. *

* Displays the possible encodings available in this JVM. Nothing fancy just a list of encoding names. No about box. * Has to be signed to allow us to look at the default encoding. * * @author Roedy Green, Canadian Mind Products * @version 1.7 2014-12-02 add count of encodings * @since 1996 */ public final class Encodings extends JApplet { // as of JDK 1.8.0_131 the following encodings were supported // Big5 // Big5-HKSCS // CESU-8 // EUC-JP // EUC-KR // GB18030 // GB2312 // GBK // IBM-Thai // IBM00858 // IBM01140 // IBM01141 // IBM01142 // IBM01143 // IBM01144 // IBM01145 // IBM01146 // IBM01147 // IBM01148 // IBM01149 // IBM037 // IBM1026 // IBM1047 // IBM273 // IBM277 // IBM278 // IBM280 // IBM284 // IBM285 // IBM290 // IBM297 // IBM420 // IBM424 // IBM437 // IBM500 // IBM775 // IBM850 // IBM852 // IBM855 // IBM857 // IBM860 // IBM861 // IBM862 // IBM863 // IBM864 // IBM865 // IBM866 // IBM868 // IBM869 // IBM870 // IBM871 // IBM918 // ISO-2022-CN // ISO-2022-JP // ISO-2022-JP-2 // ISO-2022-KR // ISO-8859-1 // ISO-8859-13 // ISO-8859-15 // ISO-8859-2 // ISO-8859-3 // ISO-8859-4 // ISO-8859-5 // ISO-8859-6 // ISO-8859-7 // ISO-8859-8 // ISO-8859-9 // JIS_X0201 // JIS_X0212-1990 // KOI8-R // KOI8-U // Shift_JIS // TIS-620 // US-ASCII // UTF-16 // UTF-16BE // UTF-16LE // UTF-32 // UTF-32BE // UTF-32LE // UTF-8 // windows-1250 // windows-1251 // windows-1252 // windows-1253 // windows-1254 // windows-1255 // windows-1256 // windows-1257 // windows-1258 // windows-31j // x-Big5-HKSCS-2001 // x-Big5-Solaris // x-euc-jp-linux // x-EUC-TW // x-eucJP-Open // x-IBM1006 // x-IBM1025 // x-IBM1046 // x-IBM1097 // x-IBM1098 // x-IBM1112 // x-IBM1122 // x-IBM1123 // x-IBM1124 // x-IBM1364 // x-IBM1381 // x-IBM1383 // x-IBM300 // x-IBM33722 // x-IBM737 // x-IBM833 // x-IBM834 // x-IBM856 // x-IBM874 // x-IBM875 // x-IBM921 // x-IBM922 // x-IBM930 // x-IBM933 // x-IBM935 // x-IBM937 // x-IBM939 // x-IBM942 // x-IBM942C // x-IBM943 // x-IBM943C // x-IBM948 // x-IBM949 // x-IBM949C // x-IBM950 // x-IBM964 // x-IBM970 // x-ISCII91 // x-ISO-2022-CN-CNS // x-ISO-2022-CN-GB // x-iso-8859-11 // x-JIS0208 // x-JISAutoDetect // x-Johab // x-MacArabic // x-MacCentralEurope // x-MacCroatian // x-MacCyrillic // x-MacDingbat // x-MacGreek // x-MacHebrew // x-MacIceland // x-MacRoman // x-MacRomania // x-MacSymbol // x-MacThai // x-MacTurkish // x-MacUkraine // x-MS932_0213 // x-MS950-HKSCS // x-MS950-HKSCS-XP // x-mswin-936 // x-PCK // x-SJIS_0213 // x-UTF-16LE-BOM // X-UTF-32BE-BOM // X-UTF-32LE-BOM // x-windows-50220 // x-windows-50221 // x-windows-874 // x-windows-949 // x-windows-950 // x-windows-iso2022jp /** * height of Applet box in pixels. Does not include surrounding frame. */ private static final int APPLET_HEIGHT = 720; /** * Width of Applet box in pixels. */ private static final int APPLET_WIDTH = 180; private static final int FIRST_COPYRIGHT_YEAR = 1996; /** * max length of an encoding name */ private static final int MAX_LINE_LENGTH = "x-windows-iso2022jp".length(); /** * undisplayed copyright notice */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 1996-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; @SuppressWarnings( { "UnusedDeclaration" } ) private static final String RELEASE_DATE = "2014-12-02"; @SuppressWarnings( { "UnusedDeclaration" } ) private static final String TITLE_STRING = "Encodings"; @SuppressWarnings( { "UnusedDeclaration" } ) private static final String VERSION_STRING = "1.7"; private void buildComponents() { final SortedMap sm = Charset.availableCharsets(); final int size = sm.size(); final FastCat sb = new FastCat( size * 2 + 8 ); // Charset.defaultCharset().name(); JDK 1.5+ // will trigger security violation in unsigned Applet, // since it too does a System.getProperty( "file.encoding" ); sb.append( TITLE_STRING + " " + VERSION_STRING + "\n" + size + "\n" + "SUPPORTED\n" + "ENCODINGS" ); sb.append( "\n------\n" ); try { String defaultEncoding = System.getProperty( "file.encoding" ); String canonicalName = Charset.forName( defaultEncoding ).name(); sb.append( "default:\n" ); sb.append( defaultEncoding ); sb.append( "\nofficially:\n" ); sb.append( canonicalName ); } catch ( AccessControlException e ) { sb.append( "No permission\n" + "granted\n" + "to view\n" + "the default\n" + "encoding" ); } sb.append( "\n------\n" ); for ( String key : sm.keySet() ) { sb.append( key ); sb.append( '\n' ); } JTextArea encodingList = new JTextArea( sb.toString(), size, MAX_LINE_LENGTH ); encodingList.setMargin( new Insets( 2, 2, 2, 0 ) ); JScrollPane sp = new JScrollPane( encodingList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); add( sp ); } /** * Allow this Applet to run as an application as well. * * @param args command line arguments ignored. */ public static void main( String args[] ) { HybridJ.fireup( new Encodings(), "Enc" /* too narrow for usual title */, APPLET_WIDTH, APPLET_HEIGHT ); } // end main /** * Called by the browser or Applet viewer to inform * this Applet that it is being reclaimed and that it should destroy * any resources that it has allocated. */ public void destroy() { // no object variables } /** * Called by the browser or Applet viewer to inform * this Applet that it has been loaded into the system. */ @Override public void init() { if ( !VersionCheck.isJavaVersionOK( 1, 8, 0, this ) ) { return; } Common18.setLaf(); buildComponents(); this.validate(); setVisible( true ); } }