backed out this code it causes http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10393
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352813 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2a19f556ae
commit
69b7c79463
@ -63,13 +63,7 @@ import java.text.FieldPosition;
|
|||||||
/**
|
/**
|
||||||
* Title: String Utility Description: Collection of string handling utilities
|
* Title: String Utility Description: Collection of string handling utilities
|
||||||
*
|
*
|
||||||
* Now it is quite confusing: the method pairs, in which
|
|
||||||
* one of them write data and other read written data are:
|
|
||||||
* putUncompressedUnicodeHigh and getFromUnicode
|
|
||||||
* putUncompressedUnicode and getFromUnicodeHigh
|
|
||||||
*
|
|
||||||
*@author Andrew C. Oliver
|
*@author Andrew C. Oliver
|
||||||
*@author Sergei Kozello (sergeikozello at mail.ru)
|
|
||||||
*@created May 10, 2002
|
*@created May 10, 2002
|
||||||
*@version 1.0
|
*@version 1.0
|
||||||
*/
|
*/
|
||||||
@ -85,8 +79,6 @@ public class StringUtil {
|
|||||||
* given a byte array of 16-bit unicode characters, compress to 8-bit and
|
* given a byte array of 16-bit unicode characters, compress to 8-bit and
|
||||||
* return a string
|
* return a string
|
||||||
*
|
*
|
||||||
* { 0x16, 0x00 } -> 0x16
|
|
||||||
*
|
|
||||||
*@param string the byte array to be converted
|
*@param string the byte array to be converted
|
||||||
*@param offset the initial offset into the
|
*@param offset the initial offset into the
|
||||||
* byte array. it is assumed that string[ offset ] and string[ offset +
|
* byte array. it is assumed that string[ offset ] and string[ offset +
|
||||||
@ -111,38 +103,23 @@ public class StringUtil {
|
|||||||
if ((len < 0) || (((string.length - offset) / 2) < len)) {
|
if ((len < 0) || (((string.length - offset) / 2) < len)) {
|
||||||
throw new IllegalArgumentException("Illegal length");
|
throw new IllegalArgumentException("Illegal length");
|
||||||
}
|
}
|
||||||
|
byte[] bstring = new byte[len];
|
||||||
|
int index = offset;
|
||||||
|
// start with high bits.
|
||||||
|
|
||||||
char[] chars = new char[ len ];
|
for (int k = 0; k < len; k++) {
|
||||||
for ( int i = 0; i < chars.length; i++ ) {
|
bstring[k] = string[index];
|
||||||
chars[i] = (char)( string[ offset + ( 2*i ) ] +
|
index += 2;
|
||||||
( string[ offset + ( 2*i+1 ) ] << 8 ) );
|
}
|
||||||
|
return new String(bstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String( chars );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* given a byte array of 16-bit unicode characters, compress to 8-bit and
|
* given a byte array of 16-bit unicode characters, compress to 8-bit and
|
||||||
* return a string
|
* return a string
|
||||||
*
|
*
|
||||||
* { 0x16, 0x00 } -> 0x16
|
|
||||||
*
|
|
||||||
*@param string the byte array to be converted
|
|
||||||
*@return the converted string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static String getFromUnicodeHigh( final byte[] string ) {
|
|
||||||
return getFromUnicodeHigh( string, 0, string.length / 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* given a byte array of 16-bit unicode characters, compress to 8-bit and
|
|
||||||
* return a string
|
|
||||||
*
|
|
||||||
* { 0x00, 0x16 } -> 0x16
|
|
||||||
*
|
|
||||||
*@param string the byte array to be converted
|
*@param string the byte array to be converted
|
||||||
*@param offset the initial offset into the
|
*@param offset the initial offset into the
|
||||||
* byte array. it is assumed that string[ offset ] and string[ offset +
|
* byte array. it is assumed that string[ offset ] and string[ offset +
|
||||||
@ -167,15 +144,15 @@ public class StringUtil {
|
|||||||
if ((len < 0) || (((string.length - offset) / 2) < len)) {
|
if ((len < 0) || (((string.length - offset) / 2) < len)) {
|
||||||
throw new IllegalArgumentException("Illegal length");
|
throw new IllegalArgumentException("Illegal length");
|
||||||
}
|
}
|
||||||
|
byte[] bstring = new byte[len];
|
||||||
|
int index = offset + 1;
|
||||||
|
// start with low bits.
|
||||||
|
|
||||||
|
for (int k = 0; k < len; k++) {
|
||||||
char[] chars = new char[ len ];
|
bstring[k] = string[index];
|
||||||
for ( int i = 0; i < chars.length; i++ ) {
|
index += 2;
|
||||||
chars[i] = (char)( ( string[ offset + ( 2*i ) ] << 8 ) +
|
|
||||||
string[ offset + ( 2*i+1 ) ] );
|
|
||||||
}
|
}
|
||||||
|
return new String(bstring);
|
||||||
return new String( chars );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -183,8 +160,6 @@ public class StringUtil {
|
|||||||
* given a byte array of 16-bit unicode characters, compress to 8-bit and
|
* given a byte array of 16-bit unicode characters, compress to 8-bit and
|
||||||
* return a string
|
* return a string
|
||||||
*
|
*
|
||||||
* { 0x00, 0x16 } -> 0x16
|
|
||||||
*
|
|
||||||
*@param string the byte array to be converted
|
*@param string the byte array to be converted
|
||||||
*@return the converted string
|
*@return the converted string
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user