Mercurial Hosting > luan
diff 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 |
line wrap: on
line diff
--- a/core/src/luan/modules/StringLuan.java Thu Dec 18 12:06:56 2014 +0000 +++ b/core/src/luan/modules/StringLuan.java Fri Dec 19 07:50:46 2014 +0000 @@ -51,16 +51,13 @@ return i==null ? dflt : end(s,i); } - @LuanMethod public static Integer[] byte_(String s,Integer i,Integer j) { - if( i== null ) - i = 1; - if( j==null ) - j = i; - s = s.substring(i-1,j); - char[] a = s.toCharArray(); - Integer[] chars = new Integer[a.length]; - for( int k=0; k<a.length; k++ ) { - chars[k] = (int)a[k]; + @LuanMethod public static Integer[] unicode(LuanState luan,String s,Integer i,Integer j) throws LuanException { + Utils.checkNotNull(luan,s); + int start = start(s,i,1); + int end = end(s,j,start+1); + Integer[] chars = new Integer[end-start]; + for( int k=0; k<chars.length; k++ ) { + chars[k] = (int)s.charAt(start+k); } return chars; }