Skip to content

Commit 9d2d39d

Browse files
Drop Encoding.toAsciiLowerCase; use toLowerCase()
This change drops the Encoding.toAsciiLowerCase() method and replaces calls to it with calls to string.toLowerCase() — because none of the conforming encoding names have any special characters for which the behavior of Encoding.toAsciiLowerCase() would produce any different results than string.toLowerCase() does.
1 parent beb060b commit 9d2d39d

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

src/nu/validator/htmlparser/io/Driver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public void setEncoding(Encoding encoding, Confidence confidence) {
336336
public boolean internalEncodingDeclaration(String internalCharset)
337337
throws SAXException {
338338
try {
339-
internalCharset = Encoding.toAsciiLowerCase(internalCharset);
339+
internalCharset = internalCharset.toLowerCase();
340340
Encoding cs;
341341
if ("utf-16".equals(internalCharset)
342342
|| "utf-16be".equals(internalCharset)
@@ -428,7 +428,7 @@ protected Encoding encodingFromExternalDeclaration(String encoding)
428428
if (encoding == null) {
429429
return null;
430430
}
431-
encoding = Encoding.toAsciiLowerCase(encoding);
431+
encoding = encoding.toLowerCase();
432432
try {
433433
Encoding cs = Encoding.forName(encoding);
434434
if ("utf-16".equals(cs.getCanonName())

src/nu/validator/htmlparser/io/Encoding.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -425,21 +425,6 @@ public static String toNameKey(String str) {
425425
return new String(buf, 0, j);
426426
}
427427

428-
public static String toAsciiLowerCase(String str) {
429-
if (str == null) {
430-
return null;
431-
}
432-
char[] buf = new char[str.length()];
433-
for (int i = 0; i < str.length(); i++) {
434-
char c = str.charAt(i);
435-
if (c >= 'A' && c <= 'Z') {
436-
c += 0x20;
437-
}
438-
buf[i] = c;
439-
}
440-
return new String(buf);
441-
}
442-
443428
/**
444429
* @param canonName
445430
* @param charset

src/nu/validator/htmlparser/io/MetaSniffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public String getEncoding() {
159159
}
160160

161161
protected boolean tryCharset(String encoding) throws SAXException {
162-
encoding = Encoding.toAsciiLowerCase(encoding);
162+
encoding = encoding.toLowerCase();
163163
try {
164164
// XXX spec says only UTF-16
165165
if ("utf-16".equals(encoding) || "utf-16be".equals(encoding) || "utf-16le".equals(encoding) || "utf-32".equals(encoding) || "utf-32be".equals(encoding) || "utf-32le".equals(encoding)) {

0 commit comments

Comments
 (0)