diff options
author | Sverker Eriksson <[email protected]> | 2017-03-08 19:02:00 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-03-08 19:02:00 +0100 |
commit | 575cc2683af16cc702795108d40d53b3df9d4daa (patch) | |
tree | f1bdc1e10bdf852a695fa92f97fff3f76481ff94 /lib/jinterface | |
parent | 32d13d59910a384ad09682cafc83c7300c96c694 (diff) | |
download | otp-575cc2683af16cc702795108d40d53b3df9d4daa.tar.gz otp-575cc2683af16cc702795108d40d53b3df9d4daa.tar.bz2 otp-575cc2683af16cc702795108d40d53b3df9d4daa.zip |
jinterface: Do not generate atoms on old latin1 external format
Diffstat (limited to 'lib/jinterface')
-rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java | 29 | ||||
-rw-r--r-- | lib/jinterface/test/jinterface_SUITE_data/Maps.java | 10 |
2 files changed, 12 insertions, 27 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java index dca2eb7c51..e1718f8380 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java @@ -403,7 +403,6 @@ public class OtpOutputStream extends ByteArrayOutputStream { public void write_atom(final String atom) { String enc_atom; byte[] bytes; - boolean isLatin1 = true; if (atom.codePointCount(0, atom.length()) <= OtpExternal.maxAtomLength) { enc_atom = atom; @@ -416,29 +415,15 @@ public class OtpOutputStream extends ByteArrayOutputStream { OtpExternal.maxAtomLength); } - for (int offset = 0; offset < enc_atom.length();) { - final int cp = enc_atom.codePointAt(offset); - if ((cp & ~0xFF) != 0) { - isLatin1 = false; - break; - } - offset += Character.charCount(cp); - } try { - if (isLatin1) { - bytes = enc_atom.getBytes("ISO-8859-1"); - write1(OtpExternal.atomTag); - write2BE(bytes.length); + bytes = enc_atom.getBytes("UTF-8"); + final int length = bytes.length; + if (length < 256) { + write1(OtpExternal.smallAtomUtf8Tag); + write1(length); } else { - bytes = enc_atom.getBytes("UTF-8"); - final int length = bytes.length; - if (length < 256) { - write1(OtpExternal.smallAtomUtf8Tag); - write1(length); - } else { - write1(OtpExternal.atomUtf8Tag); - write2BE(length); - } + write1(OtpExternal.atomUtf8Tag); + write2BE(length); } writeN(bytes); } catch (final java.io.UnsupportedEncodingException e) { diff --git a/lib/jinterface/test/jinterface_SUITE_data/Maps.java b/lib/jinterface/test/jinterface_SUITE_data/Maps.java index e8a05245da..a1b6fa73c9 100644 --- a/lib/jinterface/test/jinterface_SUITE_data/Maps.java +++ b/lib/jinterface/test/jinterface_SUITE_data/Maps.java @@ -40,19 +40,19 @@ class Maps { public static void main(final String argv[]) { runTest(new byte[] { (byte) 131, 116, 0, 0, 0, 0 }, "#{}", 1); - runTest(new byte[] { (byte) 131, 116, 0, 0, 0, 1, 100, 0, 1, 97, 100, - 0, 1, 98 }, "#{a => b}", 2); + runTest(new byte[] { (byte) 131, 116, 0, 0, 0, 1, 119, 1, 97, 119, + 1, 98 }, "#{a => b}", 2); // make sure keys are sorted here, jinterface doesn't reorder them runTest(new byte[] { (byte) 131, 116, 0, 0, 0, 2, 97, 2, 106, - 100, 0, 1, 97, 97, 1 }, "#{2 => [],a => 1}", 3); + 119, 1, 97, 97, 1 }, "#{2 => [],a => 1}", 3); runTest(new byte[] { (byte) 131, 116, 0, 0, 0, 1, 104, 1, 97, 3, 108, - 0, 0, 0, 1, 100, 0, 1, 114, 106 }, "#{{3} => [r]}", 4); + 0, 0, 0, 1, 119, 1, 114, 106 }, "#{{3} => [r]}", 4); try { // #{2 => [],a => 1} final OtpErlangMap map = new OtpErlangMap(new OtpInputStream( new byte[] { (byte) 131, 116, 0, 0, 0, 2, 97, 2, 106, - 100, 0, 1, 97, 97, 1 })); + 119, 1, 97, 97, 1 })); if (map.arity() != 2) { fail(5); |