comparison core/src/luan/modules/StringLuan.java @ 305:5e7450ac27f2

rename String.byte() to String.unicode(); improve Binary; git-svn-id: https://luan-java.googlecode.com/svn/trunk@306 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 19 Dec 2014 07:50:46 +0000
parents 2f8938fc518c
children cbb94a7c7a9e
comparison
equal deleted inserted replaced
304:03e9cda4748d 305:5e7450ac27f2
49 49
50 static int end(String s,Integer i,int dflt) { 50 static int end(String s,Integer i,int dflt) {
51 return i==null ? dflt : end(s,i); 51 return i==null ? dflt : end(s,i);
52 } 52 }
53 53
54 @LuanMethod public static Integer[] byte_(String s,Integer i,Integer j) { 54 @LuanMethod public static Integer[] unicode(LuanState luan,String s,Integer i,Integer j) throws LuanException {
55 if( i== null ) 55 Utils.checkNotNull(luan,s);
56 i = 1; 56 int start = start(s,i,1);
57 if( j==null ) 57 int end = end(s,j,start+1);
58 j = i; 58 Integer[] chars = new Integer[end-start];
59 s = s.substring(i-1,j); 59 for( int k=0; k<chars.length; k++ ) {
60 char[] a = s.toCharArray(); 60 chars[k] = (int)s.charAt(start+k);
61 Integer[] chars = new Integer[a.length];
62 for( int k=0; k<a.length; k++ ) {
63 chars[k] = (int)a[k];
64 } 61 }
65 return chars; 62 return chars;
66 } 63 }
67 64
68 public static String char_(int... chars) { 65 public static String char_(int... chars) {