Skip to content
This repository has been archived by the owner on Apr 27, 2020. It is now read-only.

Commit

Permalink
Added switch to output some encoding values.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianonline committed Sep 18, 2016
1 parent fa864f3 commit ef89185
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ data/
.idea
src/main/main.iml
cache4.*
src/test/test.iml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public CommandLineController() {
if (CommandLineOptions.val_test != null) {
if (CommandLineOptions.val_test == 1) {
TestFeatures.test1();
} else if (CommandLineOptions.val_test == 2) {
TestFeatures.test2(user, client);
} else {
System.out.println("Unknown test " + CommandLineOptions.val_test);
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/de/fabianonline/telegram_backup/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,17 @@ public int[][] getMessageTimesMatrix(AbstractChat c) {
return result;
} catch (Exception e) { throw new RuntimeException(e); }
}

public String getEncoding() {
try {
ResultSet rs = stmt.executeQuery("PRAGMA encoding");
rs.next();
return rs.getString(1);
} catch (SQLException e) {
logger.debug("SQLException: {}", e);
return "unknown";
}
}


public LinkedList<Chat> getListOfChatsForExport() {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/de/fabianonline/telegram_backup/TestFeatures.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package de.fabianonline.telegram_backup;

import com.github.badoualy.telegram.tl.api.*;
import com.github.badoualy.telegram.api.TelegramClient;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.io.IOException;
import java.nio.charset.Charset;

class TestFeatures {
public static void test1() {
Expand Down Expand Up @@ -51,4 +53,12 @@ public static void test1() {
System.out.println("Success: " + success);
System.out.println("Unsupported constructor: " + unsupported_constructor);
}

public static void test2(UserManager user, TelegramClient client) {
// Prints system.encoding and default charset
System.out.println("Default Charset: " + Charset.defaultCharset());
System.out.println("file.encoding: " + System.getProperty("file.encoding"));
Database db = new Database(user, client, false);
System.out.println("Database encoding: " + db.getEncoding());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public void tests() {
assertEquals(Utils.compareVersions("1.0.4", "1.0.4"), Utils.VERSIONS_EQUAL);
assertEquals(Utils.compareVersions("1.0.4-pre.2", "1.0.4-pre.1"), Utils.VERSIONS_EQUAL);
assertEquals(Utils.compareVersions("1.0.4", "1.0.4-abcdef-dirty"), Utils.VERSION_2_NEWER);
assertEquals(Utils.compareVersions("1.0.5", "1.0.5-test.1"), Utils.VERSION_2_NEWER);
}
}

0 comments on commit ef89185

Please sign in to comment.