diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 97d6ce501..408affb0f 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -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; + } }