Skip to content

Commit 514edc9

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 9836218 commit 514edc9

File tree

3 files changed

+3
-32
lines changed

3 files changed

+3
-32
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public void setEncoding(Encoding encoding, Confidence confidence) {
353353
public boolean internalEncodingDeclaration(String internalCharset)
354354
throws SAXException {
355355
try {
356-
internalCharset = Encoding.toAsciiLowerCase(internalCharset);
356+
internalCharset = internalCharset.toLowerCase();
357357
Encoding cs;
358358
if ("utf-16".equals(internalCharset)
359359
|| "utf-16be".equals(internalCharset)
@@ -445,7 +445,7 @@ protected Encoding encodingFromExternalDeclaration(String encoding)
445445
if (encoding == null) {
446446
return null;
447447
}
448-
encoding = Encoding.toAsciiLowerCase(encoding);
448+
encoding = encoding.toLowerCase();
449449
try {
450450
Encoding cs = Encoding.forName(encoding);
451451
if ("utf-16".equals(cs.getCanonName())

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

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

428-
public static String stripDashAndUnderscore(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 == '-' || c == '_') {
436-
buf[i] = c;
437-
}
438-
}
439-
return new String(buf);
440-
}
441-
442-
public static String toAsciiLowerCase(String str) {
443-
if (str == null) {
444-
return null;
445-
}
446-
char[] buf = new char[str.length()];
447-
for (int i = 0; i < str.length(); i++) {
448-
char c = str.charAt(i);
449-
if (c >= 'A' && c <= 'Z') {
450-
c += 0x20;
451-
}
452-
buf[i] = c;
453-
}
454-
return new String(buf);
455-
}
456-
457428
/**
458429
* @param canonName
459430
* @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)