comparison src/luan/modules/BinaryLuan.java @ 1257:e38f5869e9df

don't reset in send_redirect and other improvements
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 20 Sep 2018 21:04:41 -0600
parents 1a68fc55a80c
children 25746915a241
comparison
equal deleted inserted replaced
1256:c147e2e877e3 1257:e38f5869e9df
1 package luan.modules; 1 package luan.modules;
2 2
3 import java.io.UnsupportedEncodingException;
3 import luan.Luan; 4 import luan.Luan;
4 import luan.LuanState; 5 import luan.LuanState;
5 import luan.LuanTable; 6 import luan.LuanTable;
6 import luan.LuanFunction; 7 import luan.LuanFunction;
7 import luan.LuanException; 8 import luan.LuanException;
41 42
42 @LuanMethod public static byte[] binary(byte... bytes) { 43 @LuanMethod public static byte[] binary(byte... bytes) {
43 return bytes; 44 return bytes;
44 } 45 }
45 46
46 public static String to_string(byte[] binary) { 47 private static String toString(byte[] a) {
47 return new String(binary); 48 char[] ac = new char[a.length];
49 for( int i=0; i<a.length; i++ ) {
50 ac[i] = (char)a[i];
51 }
52 return new String(ac);
53 }
54
55 public static String to_string(byte[] binary,String charsetName) throws LuanException, UnsupportedEncodingException {
56 Utils.checkNotNull(binary);
57 return charsetName!=null ? new String(binary,charsetName) : toString(binary);
48 } 58 }
49 59
50 } 60 }