Question: Please help with my code in java. Thank you! UTF 8 . java import java.util.Arrays; public class UTF 8 { public static void main (
Please help with my code in java. Thank you!
UTFjava
import java.util.Arrays;
public class UTF
public static void mainString args
System.out.printlntestByteCountfalse;
System.out.printlntestToBytesfalse;
Returns the number of bytes that are used
to encode a code point when using UTF
@param codePoint
@return the number of bytes that encode codePoint in UTF
public static int byteCountint codePoint
if codePoint
return ;
Four cases which return and respectively...
return ; For large code points which cannot be encoded.
Returns the bytes that are used
to encode a code point when using UTF
@param codePoint the code point to encode
@return the bytes that encode codePoint in UTF
public static byte toBytesint codePoint
int count byteCountcodePoint;
byte b new bytecount;
Four cases...
return b;
Provided that byteCount is defined correctly,
this method should return true.
@param print whether to print the testing chars in the console
@return true
private static boolean testByteCountboolean print
boolean bool true;
int codePoints new int
xyu~
;
for int i ; i ; i
for int j ; j ; j
bool &byteCountcodePointsi ji ;
if print
for int codePoint : codePoints
System.out.printCharactertoCharscodePoint;
System.out.println;
return bool;
Provided that toBytes is defined correctly,
this method should return true.
@param print whether to print the testing chars in the console
@return true
private static boolean testToBytesboolean print
boolean bool true;
int codePoints new int
xyu~
;
byte bytes new byte
;
bool & Arrays.equalstoBytescodePoints new byte bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes bytes;
bool & Arrays.equalstoBytescodePoints new byte bytes bytes bytes bytes;
if print
for int codePoint : codePoints
System.out.printCharactertoCharscodePoint;
System.out.println;
return bool;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
