Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AIOOB in CP50220 transcoding #55

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions test/org/jcodings/transcode/TestCP51932ToCP50220.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.jcodings.transcode;

import org.jcodings.Ptr;
import org.junit.Test;
import org.junit.Assert;
import java.util.Arrays;

public class TestCP51932ToCP50220 {
@Test
public void testCP51932ToCP50220() throws Exception {
byte[] src = "\u0000\u007F\u008E\u00A1\u008E\u00FE\u00A1\u00A1\u00A1\u00FE".getBytes("iso-8859-1");
byte[] dst = new byte[100];
Ptr srcPtr = new Ptr(0);
Ptr dstPtr = new Ptr(0);
EConv econv = TranscoderDB.open("CP51932", "CP50220", 0);
econv.convert(src, srcPtr, src.length, dst, dstPtr, dst.length, 0);

byte[] str = Arrays.copyOf(dst, dstPtr.p);

byte[] expected = "\u0000\u007F\u001B\u0024\u0042\u0021\u0023\u0050\u0000\u0021\u0021\u0021\u007E\u001B\u0028\u0042".getBytes("iso-8859-1");
byte[] actual = Arrays.copyOf(dst, dstPtr.p);
Assert.assertEquals(new String(expected), new String(actual));
}
}