Streamline utf-8 conversion.

This commit is contained in:
James Roseborough
2008-07-09 21:09:27 +00:00
parent fec0f2955f
commit c4a4e7f2cf

View File

@@ -103,26 +103,20 @@ public class LString extends LValue {
*/ */
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 ) {
default:
if ( b == 0 )
return new String(c,0,n); return new String(c,0,n);
c[p=n++] = (char) (0xff & b); c[n++] = (char) (
break; (b>=0||i>=m_length)?
case 0x80: b:
case 0xa0: (b<-32||i+1>=m_length)?
c[p] = (char) ((c[p] << 6) | ( b & 0x3f )); (((b&0x3f) << 6)
break; | (m_bytes[m_offset+(i++)]&0x3f)):
case 0xc0: (((b&0xf) << 12)
c[p=n++] = (char) (b & 0x1f); | ((m_bytes[m_offset+(i++)]&0x3f)<<6)
break; | (m_bytes[m_offset+(i++)]&0x3f))
case 0xe0: );
c[p=n++] = (char) (b & 0xf);
break;
}
} }
return new String( c, 0, n ); return new String( c, 0, n );
} }