valerybokov edited a comment on pull request #107:
URL: https://github.com/apache/pdfbox/pull/107#issuecomment-856119473
> Your code removes all after 0 and including this 0, but that is different
to what the current code does. We don't need this at this time.
Your code does the same:
public static void main(String[]args) {
String s=cutNullBytes(new byte[]{
1,2,3,0,0,0,0,0,5,4,5,4,6,0,0,0},false);
String s1=cutNullBytes(new byte[]{
1,2,3,0,0,0,0,0,5,4,5,4,6,0,0,0},true);
String s2=cutNullBytes(new byte[]{ 1,2,3,5,4,5,4,6,0,0,0,0},false);
String s3=cutNullBytes(new byte[]{ 1,2,3,5,4,5,4,6,0,0,0,0},true);
System.out.println(s.equals(s1));
System.out.println(s2.equals(s3));
}
private static String cutNullBytes(byte[]bytes, boolean useLastIndexOf) {
String label = new String(bytes);
System.out.println("label length: " + label.length() + " label
value: " + label);
if (useLastIndexOf) {
while (label.lastIndexOf(0) != -1)
{
label = label.substring(0, label.length() - 1);
}
}
else {
int index = label.indexOf(0);
if (index > -1)
label = label.substring(0, index);
}
System.out.println("label length: " + label.length() + " label
value: " + label);
return label;
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]