Skip to content

Commit

Permalink
Showing 4 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/org/jcodings/transcode/TranscoderDB.java
Original file line number Diff line number Diff line change
@@ -268,6 +268,10 @@ public static int decoratorNames(int ecflags, byte[][] decorators) {
return numDecorators;
}

public static EConv open(String source, String destination, int ecflags) {
return open(source.getBytes(), destination.getBytes(), ecflags);
}

/* rb_econv_open */
public static EConv open(byte[] source, byte[] destination, int ecflags) {
byte[][] decorators = new byte[MAX_ECFLAGS_DECORATORS][];
7 changes: 7 additions & 0 deletions test/org/jcodings/specific/BenchEconv.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jcodings.specific;

public class BenchEconv {
public static void main(String[] args) {
byte[] utf8 =
}
}
2 changes: 1 addition & 1 deletion test/org/jcodings/specific/TestEConv.java
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
public class TestEConv {
@Test
public void testUTF8toUTF16() throws Exception {
EConv econv = TranscoderDB.open("UTF-8".getBytes(), "UTF-16".getBytes(), 0);
EConv econv = TranscoderDB.open("UTF-8", "UTF-16", 0);

byte[] src = "foo".getBytes("UTF-8");
byte[] dest = new byte["foo".getBytes("UTF-16").length];
17 changes: 17 additions & 0 deletions test/org/jcodings/specific/TestUnicode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jcodings.specific;

import org.junit.Test;

import static junit.framework.Assert.*;

public class TestUnicode {
@Test
public void testUnicodeLength() throws Exception {
byte[] utf8Bytes = "mØØse".getBytes("UTF-8");

assertEquals(7, utf8Bytes.length);
assertEquals(5, UTF8Encoding.INSTANCE.strLength(utf8Bytes, 0, 7));
assertEquals(2, UTF8Encoding.INSTANCE.length(utf8Bytes[1]));
assertEquals('Ø', UTF8Encoding.INSTANCE.mbcToCode(utf8Bytes, 1, 3));
}
}

0 comments on commit 0c19ac2

Please sign in to comment.