mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 08:24:10 -08:00
Merge pull request #139 from mpoindexter/master-fix-character-numeric-value
Fix for Character.getNumericValue.
This commit is contained in:
commit
5d4f3036a7
|
@ -17,6 +17,9 @@ package org.teavm.classlib.impl.unicode;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.teavm.classlib.impl.Base46;
|
||||||
|
import org.teavm.classlib.impl.CharFlow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
|
@ -43,30 +46,20 @@ public class UnicodeHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String encodeIntByte(int[] data) {
|
public static String encodeIntByte(int[] data) {
|
||||||
char[] chars = new char[data.length / 2 * 5];
|
StringBuilder sb = new StringBuilder();
|
||||||
int j = 0;
|
Base46.encode(sb, data.length);
|
||||||
for (int i = 0; i < data.length;) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
int val = data[i++];
|
Base46.encode(sb, data[i]);
|
||||||
int shift = 32;
|
|
||||||
for (int k = 0; k < 4; ++k) {
|
|
||||||
shift -= 8;
|
|
||||||
chars[j++] = (char)('z' + ((val >> shift) & 0xFF));
|
|
||||||
}
|
}
|
||||||
chars[j++] = (char)('z' + (data[i++] & 0xFF));
|
return sb.toString();
|
||||||
}
|
|
||||||
return new String(chars);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] decodeIntByte(String text) {
|
public static int[] decodeIntByte(String text) {
|
||||||
int[] data = new int[2 * (text.length() / 5)];
|
CharFlow flow = new CharFlow(text.toCharArray());
|
||||||
int j = 0;
|
int sz = Base46.decode(flow);
|
||||||
for (int i = 0; i < data.length;) {
|
int[] data = new int[sz];
|
||||||
int val = 0;
|
for (int i = 0; i < sz; i++) {
|
||||||
for (int k = 0; k < 4; ++k) {
|
data[i] = Base46.decode(flow);
|
||||||
val = (val << 8) | (text.charAt(j++) - 'z');
|
|
||||||
}
|
|
||||||
data[i++] = val;
|
|
||||||
data[i++] = text.charAt(j++) - 'z';
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user