forked from I2P_Developers/i2p.i2p
* New getASCII() for use in findbugs cleanups for 7-bit strings
This code was supplied by zab
This commit is contained in:
@@ -1724,6 +1724,19 @@ public class DataHelper {
|
||||
throw new RuntimeException("no utf8!?");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Roughly the same as orig.getBytes("ISO-8859-1") but much faster and
|
||||
* will not throw an exception.
|
||||
*
|
||||
* @param orig non-null, must be 7-bit chars
|
||||
* @since 0.9.5
|
||||
*/
|
||||
public static byte[] getASCII(String orig) {
|
||||
byte[] rv = new byte[orig.length()];
|
||||
for (int i = 0; i < rv.length; i++) {
|
||||
rv[i] = (byte)orig.charAt(i);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user