Skip to content

Commit

Permalink
issue #103 customizable support of 8bit byte encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuhikoarase committed Dec 6, 2021
1 parent ddbf825 commit 21a329f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions java/src/main/java/com/d_project/qrcode/QR8BitByte.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void write(BitBuffer buffer) {

try {

byte[] data = getData().getBytes(QRUtil.getJISEncoding() );
byte[] data = getData().getBytes(QRCode.get8BitByteEncoding() );

for (int i = 0; i < data.length; i++) {
buffer.put(data[i], 8);
Expand All @@ -29,7 +29,7 @@ public void write(BitBuffer buffer) {

public int getLength() {
try {
return getData().getBytes(QRUtil.getJISEncoding() ).length;
return getData().getBytes(QRCode.get8BitByteEncoding() ).length;
} catch(UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage() );
}
Expand Down
8 changes: 8 additions & 0 deletions java/src/main/java/com/d_project/qrcode/QRCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,4 +577,12 @@ public BufferedImage createImage(int cellSize, int margin) throws IOException {

return image;
}

private static String _8BitByteEncoding = QRUtil.getJISEncoding();
public static void set8BitByteEncoding(final String _8BitByteEncoding) {
QRCode._8BitByteEncoding = _8BitByteEncoding;
}
public static String get8BitByteEncoding() {
return _8BitByteEncoding;
}
}

0 comments on commit 21a329f

Please sign in to comment.