Class CharacterConverter

  • All Implemented Interfaces:
    java.lang.Comparable<java.nio.charset.Charset>
    Direct Known Subclasses:
    CompressedByteArrayStream.DirectCharConverter

    public class CharacterConverter
    extends AbstractCharacterConverter
    This class is used to correctly handle international character convertions. The default character scheme converter is the 8859-1. If you want to use a different one, you must extend this class, implementing the bytes2chars and chars2bytes methods, and then assign the public member of totalcross.sys.Convert.charConverter to use your class instead of this default one. You can also use the method Convert.setDefaultConverter to change it, passing, as parameter, the prefix of your CharacterConverter class. For example, if you created a class named Iso88592CharacterConverter, call Convert.setDefaultConverter("Iso88592");

    To find out which sun.io.CharacterEncoder you're using, do:

    System.out.println(""+sun.io.ByteToCharConverter.getDefault());

    See Also:
    Convert.charConverter, Convert.setDefaultConverter(String), UTF8CharacterConverter
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CharacterConverter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      char[] bytes2chars​(byte[] bytes, int offset, int length)
      Converts the given byte array range to a char array.
      byte[] chars2bytes​(char[] chars, int offset, int length)
      Converts the given char array range to a byte array.
      • Methods inherited from class java.nio.charset.Charset

        aliases, availableCharsets, canEncode, compareTo, decode, defaultCharset, displayName, displayName, encode, encode, equals, forName, hashCode, isRegistered, isSupported, name, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CharacterConverter

        protected CharacterConverter()
    • Method Detail

      • bytes2chars

        public char[] bytes2chars​(byte[] bytes,
                                  int offset,
                                  int length)
        Converts the given byte array range to a char array.
        Specified by:
        bytes2chars in class AbstractCharacterConverter
      • chars2bytes

        public byte[] chars2bytes​(char[] chars,
                                  int offset,
                                  int length)
        Converts the given char array range to a byte array.
        Specified by:
        chars2bytes in class AbstractCharacterConverter