mirror of
https://github.com/i2p/i2p.i2p.git
synced 2026-10-23 19:32:56 +00:00
* New getASCII() for use in findbugs cleanups for 7-bit strings
This code was supplied by zab
This commit is contained in:
1 parent
8c2ddec400
commit
f2331b0603
1 file changed
+15
-2
@@ -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