public static int utf2chars ( byte [ ] src , int sindex , char [ ] dst , int dindex , int len ) { int i = sindex ; int j = dindex ; int limit = sindex + len ; while ( i < limit ) { int b = src [ i ++ ] & 0xFF ; if ( b >= 0xE0 ) { b = ( b & 0x0F ) << 12 ; b = b | ( src [ i ++ ] & 0x3F ) << 6 ; b = b | ( src [ i ++ ] & 0x3F ) ; } else if ( b >= 0xC0 ) { b = ( b & 0x1F ) << 6 ; b = b | ( src [ i ++ ] & 0x3F ) ; } dst [ j ++ ] = ( char ) b ; } return j ; }
Convert len bytes from utf8 to characters . Parameters are as in System . arraycopy Return first index in dst past the last copied char .