c是ansi编码的,java使用unicode,你转换下
解决方案 »
- android图片按手势进行移动
- 急求助,在地图是绘制两公交站点之间的线路,为何线条不连续?
- 手写签名技术是怎么实现的?高手给点思路,谢谢!
- 【新手求救】使用全局对象出现Source Not Found错误
- android 如何判断一个进程是系统进程还是用户进程?
- TextView触发方法,在线等
- 關於com.google.android.maps.MyLocationOverlay 問題
- 如何创建先隐藏后显示的activity
- android通过webservice访问数据库 模拟器能返回数据,真机不显示。
- 请问一个关于ViewPager中Webview调用JS方法的问题。
- 怎么知道每一屏显示多少字合适
- 期待高手:Android 关于视频播放半透明UI问题。
short ns = 0;
ns = (short)((hs & 0xff) << 8);
ns |= (hs & 0xff00) >> 8;
return ns;
} public static int hltonl(int hl) {
int out = 0;
out = (hl & 0xff) << 24;
out |= (hl & 0xff00) << 8;
out |= (hl & 0xff0000) >> 8;
out |= (hl & 0xff000000) >> 24;
return out;
} public static byte[] intToBytes2(int n){
byte[] b = new byte[4];
for(int i = 0;i < 4;i++){
b[i] = (byte)(n >> (24 - i * 8));
}
return b;
}
public static float hftonf(float fl) {
ByteBuffer bbuf = ByteBuffer.allocate(4);
bbuf.putFloat(fl);
byte[] fbuf = bbuf.array();
byte []cb = new byte[4];
for(int i = 0; i < 4; ++ i) {
cb[i] = fbuf[3 - i];
}
ByteBuffer nwbuf = ByteBuffer.allocate(4);
nwbuf.put(cb);
nwbuf.position(0);
float nf = 0;
try {
nf = nwbuf.getFloat();
}
catch(BufferUnderflowException e) {
System.out.println("eer");
}
return nf;
}
public static double hdtond(double dl) {
ByteBuffer bbuf = ByteBuffer.allocate(8);
bbuf.putDouble(dl);
byte[] dbuf = bbuf.array();
byte []cb = new byte[8];
for(int i = 0; i < 8; ++ i) {
cb[i] = dbuf[7 - i];
}
ByteBuffer nwbuf = ByteBuffer.allocate(8);
nwbuf.put(cb);
nwbuf.position(0);
double nd = 0;
try {
nd = nwbuf.getDouble();
}
catch(BufferUnderflowException e) {
System.out.println("eer");
}
return nd;
}
public static void printHexByte(byte[] bt)
{
for(int i = 0; i < bt.length; ++i)
{
int hex = (int) bt[i] & 0xff;
System.out.print(Integer.toHexString(hex) + " ");
}
System.out.println("leng=" + bt.length);
}
public static void printDecimalByte(byte[] bt)
{
for(int i = 0; i < bt.length; ++i)
{
int dec = (int) bt[i] & 0xff;
System.out.print(Integer.toString(dec) + " ");
}
System.out.println("leng=" + bt.length);
}
public static int leMIntToBeInt(byte [] mint)
{
if(mint.length < 4)
return Integer.MIN_VALUE;
int out = 0;
out = mint[3];
out = out << 8;
out |= mint[2];
out = out << 8;
out |= mint[1];
out = out << 8;
out |= mint[0];
return out;
}
public static byte[] intToByte(int number) {
int temp = number;
byte[] b=new byte[4];
for (int i=b.length-1;i>-1;i--){
b[i] = new Integer(temp&0xff).byteValue();
temp = temp >> 8;
}
return b;
} public static int byteToInt(byte[] b) {
int s = 0;
for (int i = 0; i < 3; i++) {
if (b[i] >= 0)
s = s + b[i];
else
s = s + 256 + b[i];
s = s * 256;
}
if (b[3] >= 0)
s = s + b[3];
else
s = s + 256 + b[3];
return s;
} public static int readUnsignedShort(int[] b){
if(b==null){
throw new NullPointerException();
}
if(b.length>2){
throw new ArrayIndexOutOfBoundsException();
}
return (b[1] << 8) + (b[0] << 0);
}
public static byte[] charToByte(char ch){
int temp=(int)ch;
byte[] b=new byte[2];
for (int i=b.length-1;i>-1;i--){
b[i] = new Integer(temp&0xff).byteValue();
temp = temp >> 8;
}
return b;
} public static char byteToChar(byte[] b){
int s=0;
if(b[0]>0)
s+=b[0];
else
s+=256+b[0];
s*=256;
if(b[1]>0)
s+=b[1];
else
s+=256+b[1];
char ch=(char)s;
return ch;
}
public static byte[] doubleToByte(double d){
byte[] b=new byte[8];
long l=Double.doubleToLongBits(d);
for(int i=0;i<b.length;i++){
b[i]=new Long(l).byteValue();
l=l>>8;
}
return b;
}
public static double byteToDouble(byte[] b){
long l; l=b[0];
l&=0xff;
l|=((long)b[1]<<8);
l&=0xffff;
l|=((long)b[2]<<16);
l&=0xffffff;
l|=((long)b[3]<<24);
l&=0xffffffffl;
l|=((long)b[4]<<32);
l&=0xffffffffffl; l|=((long)b[5]<<40);
l&=0xffffffffffffl;
l|=((long)b[6]<<48);
l|=((long)b[7]<<56);
return Double.longBitsToDouble(l);
}