Class CodepageMapper


  • public class CodepageMapper
    extends java.lang.Object
    Maps ASCII to/from Unicode, EBCDIC to/from Unicode, Ansi to/from Unicode.
    Author:
    Christopher Mindus
    See Also:
    CodepageConverter
    • Constructor Summary

      Constructors 
      Constructor Description
      CodepageMapper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static char convertAnsiToChar​(byte b)
      Converts a single Ansi byte to character.
      static char[] convertAnsiToChar​(byte[] b)
      Converts an array of Ansi bytes to an array of characters.
      static java.lang.String convertAnsiToString​(byte[] b)
      Converts an array of Ansi bytes to a string.
      static java.lang.String convertAnsiToString​(byte[] b, int offset, int length)
      Converts an array of Ansi bytes to a string.
      static char convertASCIIToChar​(byte b)
      Converts a single ASCII byte to character.
      static char[] convertASCIIToChar​(byte[] b)
      Converts an array of ASCII bytes to an array of characters.
      static java.lang.String convertASCIIToString​(byte[] b)
      Converts an array of ASCII bytes to a string.
      static java.lang.String convertASCIIToString​(byte[] b, int offset, int length)
      Converts an array of ASCII bytes to a string.
      static byte convertCharToAnsi​(char c)
      Converts a single character to Ansi byte.
      static byte[] convertCharToAnsi​(char[] c)
      Converts an array of characters to an array of Ansi bytes.
      static byte convertCharToASCII​(char c)
      Converts a single character to ASCII byte.
      static byte[] convertCharToASCII​(char[] c)
      Converts an array of characters to an array of ASCII bytes.
      static byte convertCharToEBCDIC​(char c)
      Converts a single character to EBCDIC byte.
      static byte[] convertCharToEBCDIC​(char[] c)
      Converts an array of characters to an array of EBCDIC bytes.
      static char convertEBCDICToChar​(byte b)
      Converts a single EBCDIC byte to character.
      static char[] convertEBCDICToChar​(byte[] b)
      Converts an array of EBCDIC bytes to an array of characters.
      static java.lang.String convertEBCDICToString​(byte[] b)
      Converts an array of EBCDIC bytes to a string.
      static java.lang.String convertEBCDICToString​(byte[] b, int offset, int length)
      Converts an array of EBCDIC bytes to a string.
      static byte[] convertStringToAnsi​(java.lang.String s)
      Converts a string to an array of Ansi bytes.
      static byte[] convertStringToASCII​(java.lang.String s)
      Converts a string to an array of ASCII bytes.
      static byte[] convertStringToEBCDIC​(java.lang.String s)
      Converts a string to an array of EBCDIC bytes.
      static CodepageConverter createCodepageConverter​(java.lang.String cp)
      Creates an instance of a codepage converter class.
      static CodepageConverter getAnsiConverter()
      Gets the codepage converter for Ansi.
      static CodepageConverter getASCIIConverter()
      Gets the codepage converter for ASCII.
      static int getCurrentEBCDICCodePage()
      Gets the current EBCDIC code page value, e.g.
      static CodepageConverter getEBCDICConverter()
      Gets the codepage converter for EBCDIC.
      static boolean setAnsi​(java.lang.String cp)
      Sets the Ansi codepage.
      static boolean setASCII​(java.lang.String cp)
      Sets the ASCII codepage.
      static boolean setEBCDIC​(java.lang.String cp)
      Sets the EBCDIC codepage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CodepageMapper

        public CodepageMapper()
    • Method Detail

      • createCodepageConverter

        public static CodepageConverter createCodepageConverter​(java.lang.String cp)
        Creates an instance of a codepage converter class.
        Returns:
        null if codepage is not found.
      • setAnsi

        public static boolean setAnsi​(java.lang.String cp)
        Sets the Ansi codepage.
      • setASCII

        public static boolean setASCII​(java.lang.String cp)
        Sets the ASCII codepage.
      • setEBCDIC

        public static boolean setEBCDIC​(java.lang.String cp)
        Sets the EBCDIC codepage.
      • getASCIIConverter

        public static final CodepageConverter getASCIIConverter()
        Gets the codepage converter for ASCII.
      • getAnsiConverter

        public static final CodepageConverter getAnsiConverter()
        Gets the codepage converter for Ansi.
      • getEBCDICConverter

        public static final CodepageConverter getEBCDICConverter()
        Gets the codepage converter for EBCDIC.
      • convertAnsiToChar

        public static char convertAnsiToChar​(byte b)
        Converts a single Ansi byte to character.
      • convertAnsiToChar

        public static char[] convertAnsiToChar​(byte[] b)
        Converts an array of Ansi bytes to an array of characters.
      • convertCharToAnsi

        public static byte convertCharToAnsi​(char c)
        Converts a single character to Ansi byte.
      • convertCharToAnsi

        public static byte[] convertCharToAnsi​(char[] c)
        Converts an array of characters to an array of Ansi bytes.
      • convertAnsiToString

        public static java.lang.String convertAnsiToString​(byte[] b)
        Converts an array of Ansi bytes to a string.
      • convertAnsiToString

        public static java.lang.String convertAnsiToString​(byte[] b,
                                                           int offset,
                                                           int length)
        Converts an array of Ansi bytes to a string.
      • convertStringToAnsi

        public static byte[] convertStringToAnsi​(java.lang.String s)
        Converts a string to an array of Ansi bytes.
      • convertASCIIToChar

        public static char convertASCIIToChar​(byte b)
        Converts a single ASCII byte to character.
      • convertASCIIToChar

        public static char[] convertASCIIToChar​(byte[] b)
        Converts an array of ASCII bytes to an array of characters.
      • convertCharToASCII

        public static byte convertCharToASCII​(char c)
        Converts a single character to ASCII byte.
      • convertCharToASCII

        public static byte[] convertCharToASCII​(char[] c)
        Converts an array of characters to an array of ASCII bytes.
      • convertASCIIToString

        public static java.lang.String convertASCIIToString​(byte[] b)
        Converts an array of ASCII bytes to a string.
      • convertASCIIToString

        public static java.lang.String convertASCIIToString​(byte[] b,
                                                            int offset,
                                                            int length)
        Converts an array of ASCII bytes to a string.
      • convertStringToASCII

        public static byte[] convertStringToASCII​(java.lang.String s)
        Converts a string to an array of ASCII bytes.
      • convertEBCDICToChar

        public static char convertEBCDICToChar​(byte b)
        Converts a single EBCDIC byte to character.
      • convertEBCDICToChar

        public static char[] convertEBCDICToChar​(byte[] b)
        Converts an array of EBCDIC bytes to an array of characters.
      • convertCharToEBCDIC

        public static byte convertCharToEBCDIC​(char c)
        Converts a single character to EBCDIC byte.
      • convertCharToEBCDIC

        public static byte[] convertCharToEBCDIC​(char[] c)
        Converts an array of characters to an array of EBCDIC bytes.
      • convertEBCDICToString

        public static java.lang.String convertEBCDICToString​(byte[] b)
        Converts an array of EBCDIC bytes to a string.
      • convertEBCDICToString

        public static java.lang.String convertEBCDICToString​(byte[] b,
                                                             int offset,
                                                             int length)
        Converts an array of EBCDIC bytes to a string.
      • convertStringToEBCDIC

        public static byte[] convertStringToEBCDIC​(java.lang.String s)
        Converts a string to an array of EBCDIC bytes.
      • getCurrentEBCDICCodePage

        public static int getCurrentEBCDICCodePage()
        Gets the current EBCDIC code page value, e.g. 37, 278, 500...