Streamline utf-8 conversion.
This commit is contained in:
@@ -102,27 +102,21 @@ public class LString extends LValue {
|
|||||||
* Convert to Java string using UTF-8 encoding
|
* Convert to Java string using UTF-8 encoding
|
||||||
*/
|
*/
|
||||||
public String toJavaString() {
|
public String toJavaString() {
|
||||||
char[] c = new char[m_length];
|
char[] c=new char[m_length];
|
||||||
int n=0, p=0;
|
int i, b, n=0;
|
||||||
int b;
|
for ( i=0; i<m_length; ) {
|
||||||
for ( int i=0; i<m_length; i++ ) {
|
if ((b = m_bytes[m_offset+(i++)]) == 0)
|
||||||
switch ( (b = m_bytes[m_offset+i]) & 0xe0 ) {
|
return new String(c,0,n);
|
||||||
default:
|
c[n++] = (char) (
|
||||||
if ( b == 0 )
|
(b>=0||i>=m_length)?
|
||||||
return new String( c, 0, n );
|
b:
|
||||||
c[p=n++] = (char) (0xff & b);
|
(b<-32||i+1>=m_length)?
|
||||||
break;
|
(((b&0x3f) << 6)
|
||||||
case 0x80:
|
| (m_bytes[m_offset+(i++)]&0x3f)):
|
||||||
case 0xa0:
|
(((b&0xf) << 12)
|
||||||
c[p] = (char) ((c[p] << 6) | ( b & 0x3f ));
|
| ((m_bytes[m_offset+(i++)]&0x3f)<<6)
|
||||||
break;
|
| (m_bytes[m_offset+(i++)]&0x3f))
|
||||||
case 0xc0:
|
);
|
||||||
c[p=n++] = (char) (b & 0x1f);
|
|
||||||
break;
|
|
||||||
case 0xe0:
|
|
||||||
c[p=n++] = (char) (b & 0xf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new String( c, 0, n );
|
return new String( c, 0, n );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user