CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

After running the test cases . . .


[Replies] [Reply] [View by Thread] [Help]
[Back To SNEAK Development Forum]

Posted by Cpt SAJChurchey On 2005-02-21 19:29:29
In Reply to One more thing . . . Posted by Cpt SAJChurchey On 2005-02-19 07:45:13

Cpt
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:


Guest:
Subject:
Message:
Signature:
Optional Image Link:
http://

CyberArmy::Forum v0.6
Generated In 0.02351 seconds


About Us | Privacy Policy | Mission Statement | Help