/* The list of characters that are not encoded has been *determinedasfollows: * *RFC2396states: *----- *DatacharactersthatareallowedinaURIbutdonothavea *reservedpurposearecalledunreserved.Theseincludeupper *andlowercaseletters,decimaldigits,andalimitedsetof *punctuationmarksandsymbols. * *unreserved=alphanum|mark * *mark="-"|"_"|"."|"!"|"~"|"*"|"'"|"("|")" * *Unreservedcharacterscanbeescapedwithoutchangingthe *semanticsoftheURI,butthisshouldnotbedoneunlessthe *URIisbeingusedinacontextthatdoesnotallowthe *unescapedcharactertoappear. *----- * *ItappearsthatbothNetscapeandInternetExplorerescape *allspecialcharactersfromthislistwiththeexception *of"-","_",".","*".Whileitisnotclearwhytheyare *escapingtheothercharacters,perhapsitissafestto *assumethattheremightbecontextsinwhichtheothers *areunsafeifnotescaped.Therefore,wewillusethesame *list.Itisalsonoteworthythatthisisconsistentwith *O'Reilly's"HTML:TheDefinitiveGuide"(page164). * *Asalastnote,InternetExplorerdoesnotencodethe"@" *characterwhichisclearlynotunreservedaccordingtothe *RFC.WearebeingconsistentwiththeRFCinthismatter, *asisNetscape. *
*/
dontNeedEncoding = new BitSet(256); int i; for (i = 'a'; i <= 'z'; i++) {
dontNeedEncoding.set(i);
} for (i = 'A'; i <= 'Z'; i++) {
dontNeedEncoding.set(i);
} for (i = '0'; i <= '9'; i++) {
dontNeedEncoding.set(i);
}
dontNeedEncoding.set(' '); /* encoding a space to a + is done
* in the encode() method */
dontNeedEncoding.set('-');
dontNeedEncoding.set('_');
dontNeedEncoding.set('.');
dontNeedEncoding.set('*');
boolean needToChange = false;
StringBuilder out = new StringBuilder(s.length());
CharArrayWriter charArrayWriter = new CharArrayWriter();
for (int i = 0; i < s.length();) { int c = s.charAt(i); //System.out.println("Examining character: " + c); if (dontNeedEncoding.get(c)) { if (c == ' ') {
c = '+';
needToChange = true;
} //System.out.println("Storing: " + c);
out.append((char)c);
i++;
} else { // convert to external encoding before hex conversion do {
charArrayWriter.write(c); /* *IfthischaracterrepresentsthestartofaUnicode *surrogatepair,thenpassintwocharacters.It'snot *clearwhatshouldbedoneifabytereservedinthe *surrogatepairsrangeoccursoutsideofalegal *surrogatepair.Fornow,justtreatitasifitwere *anyothercharacter.
*/ if (c >= 0xD800 && c <= 0xDBFF) { /* System.out.println(Integer.toHexString(c) +"ishighsurrogate");
*/ if ( (i+1) < s.length()) { int d = s.charAt(i+1); /* System.out.println("\tExamining" +Integer.toHexString(d));
*/ if (d >= 0xDC00 && d <= 0xDFFF) { /* System.out.println("\t" +Integer.toHexString(d) +"islowsurrogate");
*/
charArrayWriter.write(d);
i++;
}
}
}
i++;
} while (i < s.length() && !dontNeedEncoding.get((c = s.charAt(i))));
charArrayWriter.flush();
String str = charArrayWriter.toString(); byte[] ba = str.getBytes(charset); for (byte b : ba) {
out.append('%'); char ch = Character.forDigit((b >> 4) & 0xF, 16); // converting to use uppercase letter as part of // the hex value if ch is a letter. if (Character.isLetter(ch)) {
ch -= caseDiff;
}
out.append(ch);
ch = Character.forDigit(b & 0xF, 16); if (Character.isLetter(ch)) {
ch -= caseDiff;
}
out.append(ch);
}
charArrayWriter.reset();
needToChange = true;
}
}
return (needToChange? out.toString() : s);
}
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.14Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-06)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.