Skip to content

Commit 2076fae

Browse files
committed
ANDROID: add tool to generate SB qrcodes
1 parent f00b0c2 commit 2076fae

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

web/qrcode/src/main/java/net/sourceforge/smallbasic/QrEncoder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ public static void main(String[] args) throws IOException, WriterException {
4040
}
4141

4242
protected String cleanupCode(String fileText) {
43+
// remove quotes
4344
String result = fileText.replaceAll("(?mi)^\\s*?rem.*[\\r\\n]", "");
4445
result = result.replaceAll("(?mi)^\\s*?'.*[\\r\\n]", "");
4546
result = result.replaceAll("(?mi)^\\s*?#.*[\\r\\n]", "");
47+
48+
// remove extra white space
49+
result = result.replaceAll("[ \t]{2,}", " ");
50+
4651
return result.trim();
4752
}
4853

@@ -99,7 +104,7 @@ protected void process(String fileName) throws IOException,
99104
String zipText = zipBase64(fileText);
100105

101106
// encode the zipped data into a qrcode
102-
byte[] out = createQRCode(zipText, 512);
107+
byte[] out = createQRCode("smallbasic://x/" + zipText, 512);
103108

104109
writeOutput(out, fileName + ".png");
105110
}

web/qrcode/src/test/java/net/sourceforge/smallbasic/TestQrEncoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public class TestQrEncoder {
1414
@Test
1515
public void testCleanup() {
1616
QrEncoder inst = new QrEncoder();
17-
String fileText = " 'quote comments\r\n# hash comments\nREM remarks\r\n? 'hello'\n? 10";
17+
String fileText = " 'quote comments\r\n# hash comments\nREM remarks"
18+
+ "\r\n? 'hello'\n? 10";
1819
String expectedText = "? 'hello'\n? 10";
1920
String result = inst.cleanupCode(fileText);
2021
Assert.assertEquals(expectedText, result);

0 commit comments

Comments
 (0)