0

indexOf を使用して文字列内のターミネータ文字を探しています。

// character codes to look for
int[] defseps = new int[] {10, 13, 34, 36, 38, 39,41, 44, 59, 63, 93, 125};
int t = 999999999;  // big number,  We want first terminator 
int tempt = 0;

// loop through possible terminators
for (int x = 0; x < 12; x++) {
    tempt=str.indexOf(defseps[x]); // Get index of terminator
    if (defsepactivated[x] && tempt!=-1) {  // If active terminator found
        System.out.println("defsep used=" + defseps[x]);
        if (tempt < t) t = tempt; // Use this terminator if before previous found  
    }
}

このコードは & (38) や ] (93) などのターミネータを検出しますが、二重引用符 (34) は検出しません。

たとえば、str が : =THINGTHUNG";copyright ©の場合、セミコロンと & は検出されますが、二重引用符は検出されません。

他のコーディングを試す前に、なぜそうなってしまうのか、非常に感謝しています。

4

1 に答える 1