### Question:
Unicode { public static byte[] charToBytes( char car ) { if ( car <= 0x007F ) { byte[] bytes = new byte[1]; bytes[0] = ( byte ) car; return bytes; } else if ( car <= 0x07FF ) { byte[] bytes = new byte[2]; bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) ); bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } else { byte[] bytes = new byte[3]; bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) ); bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) ); bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) ); return bytes; } } private  Unicode(); static int countBytesPerChar( byte[] bytes, int pos ); static char bytesToChar( byte[] bytes ); static char bytesToChar( byte[] bytes, int pos ); static int countNbBytesPerChar( char car ); static int countBytes( char[] chars ); static int countChars( byte[] bytes ); static byte[] charToBytes( char car ); static boolean isUnicodeSubset( String str, int pos ); static boolean isUnicodeSubset( char c ); static boolean isUnicodeSubset( byte b ); static void writeUTF( ObjectOutput objectOutput, String str ); static String readUTF( ObjectInput objectInput );  }### Answer:
@Test public void testcharToBytesOne() { assertEquals( "0x00 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0000 ) ) ); assertEquals( "0x61 ", Strings.dumpBytes( Unicode.charToBytes( 'a' ) ) ); assertEquals( "0x7F ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x007F ) ) ); }
@Test public void testcharToBytesTwo() { assertEquals( "0xC2 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0080 ) ) ); assertEquals( "0xC3 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x00FF ) ) ); assertEquals( "0xC4 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0100 ) ) ); assertEquals( "0xDF 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x07FF ) ) ); }
@Test public void testcharToBytesThree() { assertEquals( "0xE0 0xA0 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0800 ) ) ); assertEquals( "0xE0 0xBF 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x0FFF ) ) ); assertEquals( "0xE1 0x80 0x80 ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0x1000 ) ) ); assertEquals( "0xEF 0xBF 0xBF ", Strings.dumpBytes( Unicode.charToBytes( ( char ) 0xFFFF ) ) ); }