1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2025-06-29 03:46:26 +00:00

Added switch to output some encoding values.

This commit is contained in:
2016-09-18 11:33:27 +02:00
parent fa864f37b7
commit ef89185439
5 changed files with 25 additions and 0 deletions

View File

@ -131,6 +131,8 @@ public class 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);
}

View File

@ -498,6 +498,17 @@ public class Database {
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() {

View File

@ -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() {
@ -51,4 +53,12 @@ class TestFeatures {
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());
}
}