After running the test cases . . . |
||
![]() Cpt SAJChurchey A NULL string returns a NULL String. I hope this is what you mean by display error. Would it best to short-circuit the function so that it returns immediately if a NULL string is sent in as input: public static String string2Bin(String str){
if(str.equals(""))
return;
/* rest of function code here */
Also, are we ignoring whitespace altogether? A space as an ASCII value, too. If we're going by the test cases snarkles made some changes would have to be made:
public static String string2Bin(String str){
str.trim();
if(str.equals(""))
return;
/* rest of function code here */
With foreign characters, the if-statement fails and falls into the UTF-16 case, where it appends 8 unnecessary zeros to the beginning of each binary value. I've double checked the ranges assuming a UTF-8 char can be contained in an 8-bit value (did I read this wrong?), but it's still not catching the if statement.
Everything else works with the above exceptions. Should I include the code to trim leading/trailing whitespace and short-circuit the function in the NULL case? Cpt SAJChurchey
C/O of Editorial OSI Staff edit0r OSI Feedback Representative Replies:
|
||
| CyberArmy::Forum v0.6 Generated In 0.02351 seconds |