mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-16 12:12:06 +01:00
Use UTF in byte to char conversions.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1951 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
c8ea8a84e9
commit
6a8fdecdc2
1 changed files with 6 additions and 5 deletions
|
@ -285,7 +285,7 @@ public class StringUtils {
|
||||||
public static String encodeBase64(String data) {
|
public static String encodeBase64(String data) {
|
||||||
byte [] bytes = null;
|
byte [] bytes = null;
|
||||||
try {
|
try {
|
||||||
bytes = data.getBytes("ISO-8859-1");
|
bytes = data.getBytes("UTF8");
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException uee) {
|
catch (UnsupportedEncodingException uee) {
|
||||||
uee.printStackTrace();
|
uee.printStackTrace();
|
||||||
|
@ -340,15 +340,16 @@ public class StringUtils {
|
||||||
* @param data a base64 encoded String to decode.
|
* @param data a base64 encoded String to decode.
|
||||||
* @return the decoded String.
|
* @return the decoded String.
|
||||||
*/
|
*/
|
||||||
public static String decodeBase64(String data) {
|
public static byte[] decodeBase64(String data) {
|
||||||
byte [] bytes = null;
|
byte [] bytes = null;
|
||||||
try {
|
try {
|
||||||
bytes = data.getBytes("ISO-8859-1");
|
bytes = data.getBytes("UTF8");
|
||||||
|
return decodeBase64(bytes).getBytes("UTF8");
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException uee) {
|
catch (UnsupportedEncodingException uee) {
|
||||||
uee.printStackTrace();
|
uee.printStackTrace();
|
||||||
}
|
}
|
||||||
return decodeBase64(bytes);
|
return new byte[] { };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -357,7 +358,7 @@ public class StringUtils {
|
||||||
* @param data a base64 encode byte array to decode.
|
* @param data a base64 encode byte array to decode.
|
||||||
* @return the decoded String.
|
* @return the decoded String.
|
||||||
*/
|
*/
|
||||||
public static String decodeBase64(byte[] data) {
|
private static String decodeBase64(byte[] data) {
|
||||||
int c, c1;
|
int c, c1;
|
||||||
int len = data.length;
|
int len = data.length;
|
||||||
StringBuffer ret = new StringBuffer((len * 3) / 4);
|
StringBuffer ret = new StringBuffer((len * 3) / 4);
|
||||||
|
|
Loading…
Reference in a new issue