mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
findbugs: deal with all the encoding issues in a unified way further getBytes() calls can getBytes(StringUtils.getPrefferedCharset()) instead
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com> This closes #467 This closes #467
This commit is contained in:
parent
897ea3db76
commit
ba5b6b152e
@ -19,6 +19,7 @@
|
||||
|
||||
package com.cloud.utils;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -32,6 +33,21 @@ import org.owasp.esapi.StringUtilities;
|
||||
public class StringUtils {
|
||||
private static final char[] hexChar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
private static Charset preferredACSCharset;
|
||||
|
||||
{
|
||||
String preferredCharset = "UTF-8";
|
||||
if (Charset.isSupported(preferredCharset)) {
|
||||
preferredACSCharset = Charset.forName(preferredCharset);
|
||||
} else {
|
||||
preferredACSCharset = Charset.defaultCharset();
|
||||
}
|
||||
}
|
||||
|
||||
public static Charset getPreferredCharset() {
|
||||
return preferredACSCharset;
|
||||
}
|
||||
|
||||
public static String join(Iterable<? extends Object> iterable, String delim) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (iterable != null) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user