2024年4月3日发(作者:)

}

else if (head[0]==-2 && head[1]==-1) {

inputCode = "UTF-16BE";

}

else {

left0 = head;

counter++;

}

}

while((len=(buffer)) == segmentSize) {

//to check the value of len

// n("len = " + len);

int i = segmentSize - 1;

if ("UTF-16LE".equals(inputCode)) {

while (i>-1) {

if ((buffer[i-1] >= 0 && buffer[i-1] <= 127) && buffer[i] ==0) {

break;}

i--;

if (i==0) {

//报错

n("File Segmentation Failed. Failed to find an "

+ "ASCII character(0x0000-0x0009) in a segment size of "+

segmentSize +" bytesn"+"Plese adjust the segmentation size.");

break;

}

}

// i = segmentSpliter(buffer,"(buffer[i-1] >= 0 || buffer[i-1] <= 127) "

// + "&& (buffer[i]==0)");

}else if ("UTF-16BE".equals(inputCode)) {

while (i>-1) {

if ((buffer[i] >= 0 && buffer[i] <= 127) && buffer[i-1] ==0) {

break;}

i--;

if (i==0) {

//报错

n("File Segmentation Failed. Failed to find an "

+ "ASCII character(0x0000-0x0009) in a segment size of "+

segmentSize +" bytesn"+"Plese adjust the segmentation size.");

break;

}

}

}else {

// the following segmentation method is not suitable for UTF-16 or UTF-32

// since they are not compatible with ASCII code

while (i>-1) {

if (buffer[i] <= 127 && buffer[i] >= 0) {

break;}

i--;

if (i==0) {

//报错

n("File Segmentation Failed. Failed to find an "

+ "ASCII character(0-127) in a segment size of "+

segmentSize +" bytesn"+"Plese adjust the segmentation size.");

break;

}

}

}

validBuffer = (buffer, i+1);

if (counter%2==0){

left0 = Range(buffer,i+1,segmentSize);

combined = concat(left1,validBuffer);

left1 = null;

} else {

left1 = Range(buffer,i+1,segmentSize);

combined = concat(left0,validBuffer);

left0 = null;

}

counter++;

converted = realConvert2(combined,);

(converted);

}

//for the end part of the document

//can't use len=(buffer) since buffer has been read into in the while loop for the last time.

if(len < segmentSize) {

//to check the value of len

n("len = " + len);

if (len>0) {

validBuffer = (buffer, len);

} else {

//in case the file length is the multiple of 8

//in this case, the length of last segment will be 0

//only need to write what's in the left0 or left1

validBuffer = null;

}