Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default charset to UTF-8 #628

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ protected static Map<String, List<String>> decodeParameters(String queryString)
public static String decodePercent(String str) {
String decoded = null;
try {
decoded = URLDecoder.decode(str, "UTF8");
decoded = URLDecoder.decode(str, "UTF-8");
} catch (UnsupportedEncodingException ignored) {
NanoHTTPD.LOG.log(Level.WARNING, "Encoding not supported, ignored", ignored);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@

public class ContentType {

private static final String ASCII_ENCODING = "US-ASCII";
public static final String ASCII_ENCODING = "US-ASCII";

public static final String UTF8_ENCODING = "UTF-8";

private static final String MULTIPART_FORM_DATA_HEADER = "multipart/form-data";

Expand Down Expand Up @@ -69,7 +71,7 @@ public ContentType(String contentTypeHeader) {
encoding = getDetailFromContentHeader(contentTypeHeader, CHARSET_PATTERN, null, 2);
} else {
contentType = "";
encoding = "UTF-8";
encoding = UTF8_ENCODING;
}
if (MULTIPART_FORM_DATA_HEADER.equalsIgnoreCase(contentType)) {
boundary = getDetailFromContentHeader(contentTypeHeader, BOUNDARY_PATTERN, null, 2);
Expand All @@ -92,7 +94,7 @@ public String getContentType() {
}

public String getEncoding() {
return encoding == null ? ASCII_ENCODING : encoding;
return encoding == null ? UTF8_ENCODING : encoding;
}

public String getBoundary() {
Expand Down