From 9807dc01866f1f9028d60d11ceb853a6c6c2e30f Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Wed, 11 Sep 2024 23:53:48 +0800
Subject: [PATCH 01/24] feat: Add new UI interface
---
.../zzhow/magicencoding/ui/Application.java | 2 +-
.../com/zzhow/magicencoding/ui/main-view.fxml | 176 +++++++++++++++---
2 files changed, 148 insertions(+), 30 deletions(-)
diff --git a/src/main/java/com/zzhow/magicencoding/ui/Application.java b/src/main/java/com/zzhow/magicencoding/ui/Application.java
index 6eac8a2..8cddeb5 100644
--- a/src/main/java/com/zzhow/magicencoding/ui/Application.java
+++ b/src/main/java/com/zzhow/magicencoding/ui/Application.java
@@ -23,7 +23,7 @@ public static void setLanguage(String language) {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(Application.class.getResource("main-view.fxml"));
- Scene scene = new Scene(fxmlLoader.load(), 700, 535);
+ Scene scene = new Scene(fxmlLoader.load(), 780, 596);
stage.setTitle("MagicEncoding");
stage.setScene(scene);
Image icon = new Image(Objects.requireNonNull(MainClass.class.getResourceAsStream("/image/icon.png")));
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index c38b074..355d612 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -6,40 +6,158 @@
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From f53c4679f4db06f98d372a52659b69576d192bcd Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 09:25:19 +0800
Subject: [PATCH 02/24] feat: Implement TabPane switching in text module
---
.../controller/MainController.java | 32 +++++++++-
.../com/zzhow/magicencoding/ui/main-view.fxml | 62 ++++---------------
2 files changed, 44 insertions(+), 50 deletions(-)
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index 3df7194..8c91a42 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -23,6 +23,8 @@ public class MainController {
// 文件服务类
private final FileService fileService = FileServiceImpl.getInstance();
+ // 字符编码索引
+ private int textSelectedIndex = 0;
@FXML
private Label Label1;
@@ -60,6 +62,13 @@ public class MainController {
private ListView filesListView;
@FXML
private CheckBox isOverwriteCheckBox;
+ @FXML
+ private TabPane textTabPane;
+ @FXML
+ private TextArea decodingText;
+ @FXML
+ private TextArea encodingText;
+
public void clearFilesPath() {
fileService.clearTargetFileList();
@@ -87,7 +96,7 @@ else if (language.contains("Hant"))
language = "zh_TW";
else if (language.contains("CN"))
language = "zh_CN";
- else
+ else
language = "zh_TW";
} else {
language = "en_US";
@@ -104,6 +113,27 @@ else if (language.contains("CN"))
switchLanguage();
}
+ @FXML
+ private void onTextTabPaneClicked() {
+ SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+
+ if (this.textSelectedIndex != selectionModel.getSelectedIndex()) {
+ this.textSelectedIndex = selectionModel.getSelectedIndex();
+ selectionModel.select(this.textSelectedIndex);
+ decodingText.clear();
+ encodingText.clear();
+ encodingText.setPromptText(selectionModel.getSelectedItem().getText());
+ }
+ }
+
+ @FXML
+ private void onDecodingText() {
+ }
+
+ @FXML
+ private void onEncodingText() {
+ }
+
@FXML
private void handleDragOver(DragEvent event) {
if (event.getGestureSource() != event.getTarget() // 是否从外部拖拽
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index 355d612..f97b68f 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -56,58 +56,22 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
From 50ddd8d2f88348870d571b4219b273fa8274dbab Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 10:40:53 +0800
Subject: [PATCH 03/24] feat: Add support for Unicode and URL encoding
---
.../controller/MainController.java | 27 +-
.../magicencoding/enums/TextEncodingType.java | 32 +++
.../zzhow/magicencoding/utils/MyTextUtil.java | 36 +++
.../com/zzhow/magicencoding/ui/main-view.fxml | 257 ++++++++++--------
4 files changed, 242 insertions(+), 110 deletions(-)
create mode 100644 src/main/java/com/zzhow/magicencoding/enums/TextEncodingType.java
create mode 100644 src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index 8c91a42..c6044af 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -1,10 +1,12 @@
package com.zzhow.magicencoding.controller;
+import com.zzhow.magicencoding.enums.TextEncodingType;
import com.zzhow.magicencoding.service.FileService;
import com.zzhow.magicencoding.service.impl.FileServiceImpl;
import com.zzhow.magicencoding.ui.About;
import com.zzhow.magicencoding.ui.Application;
import com.zzhow.magicencoding.utils.MessageBox;
+import com.zzhow.magicencoding.utils.MyTextUtil;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.Label;
@@ -14,10 +16,7 @@
import java.io.*;
import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.SortedMap;
+import java.util.*;
public class MainController {
@@ -68,6 +67,10 @@ public class MainController {
private TextArea decodingText;
@FXML
private TextArea encodingText;
+ @FXML
+ private Label urlCharsetText;
+ @FXML
+ private ChoiceBox urlCharset;
public void clearFilesPath() {
@@ -87,6 +90,9 @@ private void initialize() {
targetChoiceBox.setValue("UTF-8");
languageSelector.getItems().addAll("简体中文", "繁體中文", "English");
+ urlCharset.getItems().addAll("UTF-8", "GBK");
+ urlCharset.setValue("UTF-8");
+
String language = Locale.getDefault().toLanguageTag();
if (language.contains("zh")) {
@@ -118,7 +124,15 @@ private void onTextTabPaneClicked() {
SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
if (this.textSelectedIndex != selectionModel.getSelectedIndex()) {
+ if (this.textSelectedIndex == TextEncodingType.URL.getValue()) {
+ urlCharsetText.setVisible(false);
+ urlCharset.setVisible(false);
+ }
this.textSelectedIndex = selectionModel.getSelectedIndex();
+ if (this.textSelectedIndex == TextEncodingType.URL.getValue()) {
+ urlCharsetText.setVisible(true);
+ urlCharset.setVisible(true);
+ }
selectionModel.select(this.textSelectedIndex);
decodingText.clear();
encodingText.clear();
@@ -132,6 +146,11 @@ private void onDecodingText() {
@FXML
private void onEncodingText() {
+ SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+ String originalText = decodingText.getText();
+
+ String res = MyTextUtil.encode(originalText, urlCharset.getValue(), Objects.requireNonNull(TextEncodingType.valueOf(selectionModel.getSelectedIndex())));
+ encodingText.setText(res);
}
@FXML
diff --git a/src/main/java/com/zzhow/magicencoding/enums/TextEncodingType.java b/src/main/java/com/zzhow/magicencoding/enums/TextEncodingType.java
new file mode 100644
index 0000000..0daef07
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/enums/TextEncodingType.java
@@ -0,0 +1,32 @@
+package com.zzhow.magicencoding.enums;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public enum TextEncodingType {
+ Unicode(0), URL(1);
+
+ private final int value;
+
+ private TextEncodingType(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return this.value;
+ }
+
+ public static TextEncodingType valueOf(int value) {
+ switch (value) {
+ case 0 -> {
+ return Unicode;
+ }
+ case 1 -> {
+ return URL;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java b/src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java
new file mode 100644
index 0000000..4cf6589
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java
@@ -0,0 +1,36 @@
+package com.zzhow.magicencoding.utils;
+
+import com.zzhow.magicencoding.enums.TextEncodingType;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public class MyTextUtil {
+ public static String encode(String original, String originalCharset, TextEncodingType type) {
+ switch (type) {
+ case Unicode -> {
+ // 将字符串中的每个字符转换为 Unicode 转义序列
+ StringBuilder unicodeEncoded = new StringBuilder();
+ for (char c : original.toCharArray()) {
+ unicodeEncoded.append(String.format("\\u%04x", (int) c));
+ }
+
+ return unicodeEncoded.toString();
+ }
+ case URL -> {
+ // 使用 URLEncoder 类完成 URL 编码
+ try {
+ return URLEncoder.encode(original, originalCharset);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index f97b68f..006da1e 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -14,114 +14,159 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 6cce6ba75cce749ffbc2a9b39100b2206c91f36a Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 11:20:52 +0800
Subject: [PATCH 04/24] feat: Add support for Unicode and URL decoding
---
.../controller/MainController.java | 5 +++
.../zzhow/magicencoding/utils/MyTextUtil.java | 32 +++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index c6044af..a5cabc2 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -142,6 +142,11 @@ private void onTextTabPaneClicked() {
@FXML
private void onDecodingText() {
+ SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+ String text = encodingText.getText();
+
+ String res = MyTextUtil.decode(text, urlCharset.getValue(), Objects.requireNonNull(TextEncodingType.valueOf(selectionModel.getSelectedIndex())));
+ decodingText.setText(res);
}
@FXML
diff --git a/src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java b/src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java
index 4cf6589..b251ec0 100644
--- a/src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java
+++ b/src/main/java/com/zzhow/magicencoding/utils/MyTextUtil.java
@@ -3,7 +3,10 @@
import com.zzhow.magicencoding.enums.TextEncodingType;
import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* @author ZZHow
@@ -33,4 +36,33 @@ public static String encode(String original, String originalCharset, TextEncodin
return null;
}
+
+ public static String decode(String original, String originalCharset, TextEncodingType type) {
+ switch (type) {
+ case Unicode -> {
+ // 通过正则表达式,将字符串中的每个 Unicode 转义序列转为字符序列
+ Pattern pattern = Pattern.compile("\\\\u([0-9a-fA-F]{4})");
+ Matcher matcher = pattern.matcher(original);
+
+ StringBuilder stringBuilder = new StringBuilder();
+ while (matcher.find()) {
+ String s = String.valueOf((char) Integer.parseInt(matcher.group(1), 16));
+ matcher.appendReplacement(stringBuilder, s);
+ }
+ matcher.appendTail(stringBuilder);
+
+ return stringBuilder.toString();
+ }
+ case URL -> {
+ // 使用 URLEncoder 类完成 URL 解码
+ try {
+ return URLDecoder.decode(original, originalCharset);
+ } catch (UnsupportedEncodingException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+ }
+
+ return null;
+ }
}
From 2da888bb690412a6c0a47b3487362d675f9da4b2 Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 11:34:17 +0800
Subject: [PATCH 05/24] feat: Add content reset functionality
---
.../controller/MainController.java | 18 ++++++++++++------
.../com/zzhow/magicencoding/ui/main-view.fxml | 14 ++++++++------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index a5cabc2..b1e53cc 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -140,6 +140,15 @@ private void onTextTabPaneClicked() {
}
}
+ @FXML
+ private void onEncodingText() {
+ SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+ String originalText = decodingText.getText();
+
+ String res = MyTextUtil.encode(originalText, urlCharset.getValue(), Objects.requireNonNull(TextEncodingType.valueOf(selectionModel.getSelectedIndex())));
+ encodingText.setText(res);
+ }
+
@FXML
private void onDecodingText() {
SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
@@ -150,12 +159,9 @@ private void onDecodingText() {
}
@FXML
- private void onEncodingText() {
- SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
- String originalText = decodingText.getText();
-
- String res = MyTextUtil.encode(originalText, urlCharset.getValue(), Objects.requireNonNull(TextEncodingType.valueOf(selectionModel.getSelectedIndex())));
- encodingText.setText(res);
+ private void onTextReset() {
+ decodingText.clear();
+ encodingText.clear();
}
@FXML
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index 006da1e..0755567 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -87,15 +87,17 @@
promptText="文本内容"/>
-
-
+
+
-
+
From ccbbfc458ff762c0aec0b1d83a6c3ae8ef474e65 Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 11:55:49 +0800
Subject: [PATCH 06/24] refactor: Add new text service class
---
.../controller/MainController.java | 23 ++++++++------
.../magicencoding/service/TextService.java | 31 +++++++++++++++++++
.../service/impl/TextServiceImpl.java | 31 +++++++++++++++++++
.../com/zzhow/magicencoding/ui/main-view.fxml | 4 +--
4 files changed, 78 insertions(+), 11 deletions(-)
create mode 100644 src/main/java/com/zzhow/magicencoding/service/TextService.java
create mode 100644 src/main/java/com/zzhow/magicencoding/service/impl/TextServiceImpl.java
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index b1e53cc..906c735 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -2,11 +2,12 @@
import com.zzhow.magicencoding.enums.TextEncodingType;
import com.zzhow.magicencoding.service.FileService;
+import com.zzhow.magicencoding.service.TextService;
import com.zzhow.magicencoding.service.impl.FileServiceImpl;
+import com.zzhow.magicencoding.service.impl.TextServiceImpl;
import com.zzhow.magicencoding.ui.About;
import com.zzhow.magicencoding.ui.Application;
import com.zzhow.magicencoding.utils.MessageBox;
-import com.zzhow.magicencoding.utils.MyTextUtil;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.Label;
@@ -22,6 +23,8 @@ public class MainController {
// 文件服务类
private final FileService fileService = FileServiceImpl.getInstance();
+ // 文本服务类
+ private final TextService textService = TextServiceImpl.getInstance();
// 字符编码索引
private int textSelectedIndex = 0;
@@ -141,21 +144,23 @@ private void onTextTabPaneClicked() {
}
@FXML
- private void onEncodingText() {
- SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+ private void onEncodeText() {
String originalText = decodingText.getText();
+ String originalCharset = urlCharset.getValue();
+ SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+ TextEncodingType type = TextEncodingType.valueOf(selectionModel.getSelectedIndex());
- String res = MyTextUtil.encode(originalText, urlCharset.getValue(), Objects.requireNonNull(TextEncodingType.valueOf(selectionModel.getSelectedIndex())));
- encodingText.setText(res);
+ encodingText.setText(textService.encodeText(originalText, originalCharset, type));
}
@FXML
- private void onDecodingText() {
- SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+ private void onDecodeText() {
String text = encodingText.getText();
+ String originalCharset = urlCharset.getValue();
+ SingleSelectionModel selectionModel = textTabPane.getSelectionModel();
+ TextEncodingType type = TextEncodingType.valueOf(selectionModel.getSelectedIndex());
- String res = MyTextUtil.decode(text, urlCharset.getValue(), Objects.requireNonNull(TextEncodingType.valueOf(selectionModel.getSelectedIndex())));
- decodingText.setText(res);
+ decodingText.setText(textService.decodeText(text, originalCharset, type));
}
@FXML
diff --git a/src/main/java/com/zzhow/magicencoding/service/TextService.java b/src/main/java/com/zzhow/magicencoding/service/TextService.java
new file mode 100644
index 0000000..ff077a8
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/service/TextService.java
@@ -0,0 +1,31 @@
+package com.zzhow.magicencoding.service;
+
+import com.zzhow.magicencoding.enums.TextEncodingType;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public interface TextService {
+
+ /**
+ * 字符文本编码
+ *
+ * @param original 原始字符串
+ * @param originalCharset 原始字符集
+ * @param type 编码类型
+ * @return 编码后的字符串
+ */
+ String encodeText(String original, String originalCharset, TextEncodingType type);
+
+ /**
+ * 字符文本解码
+ *
+ * @param original 编码过的字符串
+ * @param originalCharset 原始字符集
+ * @param type 解码类型
+ * @return 解码后的字符串
+ */
+ String decodeText(String original, String originalCharset, TextEncodingType type);
+
+}
diff --git a/src/main/java/com/zzhow/magicencoding/service/impl/TextServiceImpl.java b/src/main/java/com/zzhow/magicencoding/service/impl/TextServiceImpl.java
new file mode 100644
index 0000000..8b694f4
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/service/impl/TextServiceImpl.java
@@ -0,0 +1,31 @@
+package com.zzhow.magicencoding.service.impl;
+
+import com.zzhow.magicencoding.enums.TextEncodingType;
+import com.zzhow.magicencoding.service.TextService;
+import com.zzhow.magicencoding.utils.MyTextUtil;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public class TextServiceImpl implements TextService {
+ private static final TextService textService = new TextServiceImpl();
+
+ private TextServiceImpl() {
+
+ }
+
+ public static TextService getInstance() {
+ return textService;
+ }
+
+ @Override
+ public String encodeText(String original, String originalCharset, TextEncodingType type) {
+ return MyTextUtil.encode(original, originalCharset, type);
+ }
+
+ @Override
+ public String decodeText(String original, String originalCharset, TextEncodingType type) {
+ return MyTextUtil.decode(original, originalCharset, type);
+ }
+}
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index 0755567..fc058eb 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -88,9 +88,9 @@
+ onAction="#onDecodeText" prefWidth="80.0" text="↑"/>
+ onAction="#onEncodeText" prefWidth="80.0" text="↓"/>
From db55b135b433fbb34d410f550079d7a7a8725e4a Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 11:58:47 +0800
Subject: [PATCH 07/24] chore: Minor UI adjustments
---
src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index fc058eb..a1cc284 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -85,7 +85,7 @@
-
From 6fd391aafefe92e5c215ef0ec58cc41c142baa22 Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 19:52:48 +0800
Subject: [PATCH 08/24] feat: Add basic functionality for Unix timestamp module
---
.../controller/MainController.java | 71 +++++++++++++++++++
.../zzhow/magicencoding/ui/Application.java | 3 +
src/main/java/module-info.java | 1 +
.../com/zzhow/magicencoding/ui/main-view.fxml | 47 ++++++------
4 files changed, 102 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index 906c735..3944049 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -10,14 +10,19 @@
import com.zzhow.magicencoding.utils.MessageBox;
import javafx.fxml.FXML;
import javafx.scene.control.*;
+import javafx.scene.control.Button;
import javafx.scene.control.Label;
+import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.DragEvent;
import javafx.scene.input.TransferMode;
+import java.awt.*;
+import java.awt.datatransfer.StringSelection;
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
+import java.util.List;
public class MainController {
@@ -27,6 +32,11 @@ public class MainController {
private final TextService textService = TextServiceImpl.getInstance();
// 字符编码索引
private int textSelectedIndex = 0;
+ // 主页索引
+ private int selectedIndex = 0;
+ // 计时器
+ private Timer timer = null;
+ private boolean timerRunning = false;
@FXML
private Label Label1;
@@ -74,6 +84,26 @@ public class MainController {
private Label urlCharsetText;
@FXML
private ChoiceBox urlCharset;
+ @FXML
+ private TextField nowTimestamp;
+ @FXML
+ private TabPane tabPane;
+ @FXML
+ private TextField timeTextField1;
+ @FXML
+ private TextField timeTextField2;
+ @FXML
+ private TextField timeTextField3;
+ @FXML
+ private TextField timeTextField4;
+ @FXML
+ private TextField timeTextField5;
+ @FXML
+ private TextField timeTextField6;
+ @FXML
+ private TextField timeTextField7;
+ @FXML
+ private TextField timeTextField8;
public void clearFilesPath() {
@@ -143,6 +173,47 @@ private void onTextTabPaneClicked() {
}
}
+ @FXML
+ private void onTabPaneClicked() {
+ SingleSelectionModel selectionModel = this.tabPane.getSelectionModel();
+
+ if (this.selectedIndex != selectionModel.getSelectedIndex()) {
+ this.selectedIndex = selectionModel.getSelectedIndex();
+ if (timerRunning) {
+ timer.cancel();
+ timerRunning = false;
+ } else if (selectionModel.getSelectedIndex() == 2) {
+ this.timer = new Timer();
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ nowTimestamp.clear();
+ nowTimestamp.setText(String.valueOf(System.currentTimeMillis()));
+ }
+ }, 0, 800);
+ timerRunning = true;
+ }
+ }
+ }
+
+ @FXML
+ private void onCopyTimestamp() {
+ StringSelection stringSelection = new StringSelection(nowTimestamp.getText());
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
+ }
+
+ @FXML
+ private void onTimeReset() {
+ timeTextField1.clear();
+ timeTextField2.clear();
+ timeTextField3.clear();
+ timeTextField4.clear();
+ timeTextField5.clear();
+ timeTextField6.clear();
+ timeTextField7.clear();
+ timeTextField8.clear();
+ }
+
@FXML
private void onEncodeText() {
String originalText = decodingText.getText();
diff --git a/src/main/java/com/zzhow/magicencoding/ui/Application.java b/src/main/java/com/zzhow/magicencoding/ui/Application.java
index 8cddeb5..6216de4 100644
--- a/src/main/java/com/zzhow/magicencoding/ui/Application.java
+++ b/src/main/java/com/zzhow/magicencoding/ui/Application.java
@@ -29,6 +29,9 @@ public void start(Stage stage) throws IOException {
Image icon = new Image(Objects.requireNonNull(MainClass.class.getResourceAsStream("/image/icon.png")));
stage.getIcons().add(icon);
stage.setResizable(false);
+ stage.setOnHiding(windowEvent -> {
+ System.exit(0);
+ });
stage.show();
}
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index 7624d38..9271813 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -3,6 +3,7 @@
requires javafx.fxml;
requires java.desktop;
requires com.github.albfernandez.juniversalchardet;
+ requires java.sql;
opens com.zzhow.magicencoding to javafx.fxml;
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index a1cc284..7031525 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -19,7 +19,8 @@
-
+
@@ -97,7 +98,7 @@
+ onAction="#onTextReset" prefWidth="80.0" text="重置"/>
@@ -111,12 +112,16 @@
-
-
-
+
+
+
-
+
@@ -125,18 +130,18 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
From e2d1436871d688fb6891392fd3e01e3d72694878 Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 22:26:15 +0800
Subject: [PATCH 09/24] feat: Implement conversion between timestamps and
human-readable dates
---
.../controller/MainController.java | 73 +++++--
.../magicencoding/service/TimeService.java | 28 +++
.../service/impl/TimeServiceImpl.java | 41 ++++
.../zzhow/magicencoding/utils/MyTimeUtil.java | 23 +++
.../com/zzhow/magicencoding/ui/main-view.fxml | 182 +++++++-----------
5 files changed, 211 insertions(+), 136 deletions(-)
create mode 100644 src/main/java/com/zzhow/magicencoding/service/TimeService.java
create mode 100644 src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java
create mode 100644 src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index 3944049..f3f70f9 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -3,8 +3,10 @@
import com.zzhow.magicencoding.enums.TextEncodingType;
import com.zzhow.magicencoding.service.FileService;
import com.zzhow.magicencoding.service.TextService;
+import com.zzhow.magicencoding.service.TimeService;
import com.zzhow.magicencoding.service.impl.FileServiceImpl;
import com.zzhow.magicencoding.service.impl.TextServiceImpl;
+import com.zzhow.magicencoding.service.impl.TimeServiceImpl;
import com.zzhow.magicencoding.ui.About;
import com.zzhow.magicencoding.ui.Application;
import com.zzhow.magicencoding.utils.MessageBox;
@@ -21,8 +23,11 @@
import java.awt.datatransfer.StringSelection;
import java.io.*;
import java.nio.charset.Charset;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.List;
+import java.util.concurrent.TimeUnit;
public class MainController {
@@ -30,13 +35,12 @@ public class MainController {
private final FileService fileService = FileServiceImpl.getInstance();
// 文本服务类
private final TextService textService = TextServiceImpl.getInstance();
+ // 时间服务类
+ private final TimeService timeService = TimeServiceImpl.getInstance();
// 字符编码索引
private int textSelectedIndex = 0;
// 主页索引
private int selectedIndex = 0;
- // 计时器
- private Timer timer = null;
- private boolean timerRunning = false;
@FXML
private Label Label1;
@@ -85,7 +89,9 @@ public class MainController {
@FXML
private ChoiceBox urlCharset;
@FXML
- private TextField nowTimestamp;
+ private TextField nowTimestampS;
+ @FXML
+ private TextField nowTimestampMs;
@FXML
private TabPane tabPane;
@FXML
@@ -104,6 +110,10 @@ public class MainController {
private TextField timeTextField7;
@FXML
private TextField timeTextField8;
+ @FXML
+ private ChoiceBox secondTypeChoiceBox;
+ @FXML
+ private ChoiceBox timeOperationType;
public void clearFilesPath() {
@@ -126,6 +136,9 @@ private void initialize() {
urlCharset.getItems().addAll("UTF-8", "GBK");
urlCharset.setValue("UTF-8");
+ secondTypeChoiceBox.getItems().addAll("秒", "毫秒");
+ secondTypeChoiceBox.setValue("秒");
+
String language = Locale.getDefault().toLanguageTag();
if (language.contains("zh")) {
@@ -179,27 +192,15 @@ private void onTabPaneClicked() {
if (this.selectedIndex != selectionModel.getSelectedIndex()) {
this.selectedIndex = selectionModel.getSelectedIndex();
- if (timerRunning) {
- timer.cancel();
- timerRunning = false;
- } else if (selectionModel.getSelectedIndex() == 2) {
- this.timer = new Timer();
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- nowTimestamp.clear();
- nowTimestamp.setText(String.valueOf(System.currentTimeMillis()));
- }
- }, 0, 800);
- timerRunning = true;
- }
+ if (selectionModel.getSelectedIndex() == 2)
+ this.onRefreshTimestamp();
}
}
@FXML
- private void onCopyTimestamp() {
- StringSelection stringSelection = new StringSelection(nowTimestamp.getText());
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
+ private void onRefreshTimestamp() {
+ this.nowTimestampS.setText(System.currentTimeMillis() / 1000 + "");
+ this.nowTimestampMs.setText(System.currentTimeMillis() + "");
}
@FXML
@@ -214,6 +215,36 @@ private void onTimeReset() {
timeTextField8.clear();
}
+ @FXML
+ private void onTimestampToTime() {
+ String text = timeTextField1.getText();
+ TimeUnit timeUnit = secondTypeChoiceBox.getSelectionModel().getSelectedIndex() == 0 ? TimeUnit.SECONDS : TimeUnit.MILLISECONDS;
+ if (text == null || text.isEmpty())
+ return;
+ try {
+ long timestamp = Long.parseLong(text);
+ timeTextField2.setText(timeService.timestampToTime(timestamp, timeUnit));
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ @FXML
+ private void onTimeToTimestamp() {
+ String text = timeTextField2.getText();
+ TimeUnit timeUnit = secondTypeChoiceBox.getSelectionModel().getSelectedIndex() == 0 ? TimeUnit.SECONDS : TimeUnit.MILLISECONDS;
+ if (text == null || text.isEmpty())
+ return;
+
+ try {
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ LocalDateTime localDateTime = LocalDateTime.parse(timeTextField2.getText(), dateTimeFormatter);
+ timeTextField1.setText(timeService.timeToTimestamp(localDateTime, timeUnit));
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
@FXML
private void onEncodeText() {
String originalText = decodingText.getText();
diff --git a/src/main/java/com/zzhow/magicencoding/service/TimeService.java b/src/main/java/com/zzhow/magicencoding/service/TimeService.java
new file mode 100644
index 0000000..7a49460
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/service/TimeService.java
@@ -0,0 +1,28 @@
+package com.zzhow.magicencoding.service;
+
+import java.time.LocalDateTime;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public interface TimeService {
+
+ /**
+ * 时间戳转时间
+ *
+ * @param timestamp 时间戳
+ * @return 时间
+ */
+ public String timestampToTime(long timestamp, TimeUnit unit);
+
+ /**
+ * 时间转时间戳
+ *
+ * @param time 时间
+ * @return 时间戳
+ */
+ public String timeToTimestamp(LocalDateTime time, TimeUnit unit);
+
+}
diff --git a/src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java b/src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java
new file mode 100644
index 0000000..ed3579f
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java
@@ -0,0 +1,41 @@
+package com.zzhow.magicencoding.service.impl;
+
+import com.zzhow.magicencoding.service.TimeService;
+import com.zzhow.magicencoding.utils.MyTimeUtil;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public class TimeServiceImpl implements TimeService {
+ private static final TimeService timeService = new TimeServiceImpl();
+
+ private TimeServiceImpl() {
+
+ }
+
+ public static TimeService getInstance() {
+ return timeService;
+ }
+
+ @Override
+ public String timestampToTime(long timestamp, TimeUnit unit) {
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+ if (unit == TimeUnit.MILLISECONDS)
+ timestamp /= 1000;
+
+ return dateTimeFormatter.format(MyTimeUtil.timestampToLocalDateTime(timestamp));
+ }
+
+ @Override
+ public String timeToTimestamp(LocalDateTime time, TimeUnit unit) {
+ long timestamp = MyTimeUtil.localDateTimeToTimestamp(time);
+
+ return String.valueOf(unit == TimeUnit.SECONDS ? timestamp / 1000 : timestamp);
+ }
+}
diff --git a/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java b/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
new file mode 100644
index 0000000..958f3f9
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
@@ -0,0 +1,23 @@
+package com.zzhow.magicencoding.utils;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public class MyTimeUtil {
+
+ public static LocalDateTime timestampToLocalDateTime(long timestamp) {
+ Instant instant = Instant.ofEpochSecond(timestamp);
+
+ return instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
+ }
+
+ public static long localDateTimeToTimestamp(LocalDateTime localDateTime) {
+ return localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
+ }
+
+}
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index 7031525..dcde699 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -14,155 +14,108 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
@@ -171,11 +124,10 @@
-
-
-
-
+
+
+
+
From 9e6fff0193a045bb57411cc2b21083b5846e9f1d Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 23:01:29 +0800
Subject: [PATCH 10/24] feat: Add quick time manipulation functions
- forward/backward by year, month, day, hour, minute, second
---
.../controller/MainController.java | 28 +++
.../enums/TimeOperationType.java | 27 +++
.../magicencoding/service/TimeService.java | 16 ++
.../service/impl/TimeServiceImpl.java | 58 ++++++
.../zzhow/magicencoding/utils/MyTimeUtil.java | 23 +++
.../com/zzhow/magicencoding/ui/main-view.fxml | 182 ++++++++++++------
6 files changed, 271 insertions(+), 63 deletions(-)
create mode 100644 src/main/java/com/zzhow/magicencoding/enums/TimeOperationType.java
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index f3f70f9..d794f8a 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -1,6 +1,7 @@
package com.zzhow.magicencoding.controller;
import com.zzhow.magicencoding.enums.TextEncodingType;
+import com.zzhow.magicencoding.enums.TimeOperationType;
import com.zzhow.magicencoding.service.FileService;
import com.zzhow.magicencoding.service.TextService;
import com.zzhow.magicencoding.service.TimeService;
@@ -138,6 +139,8 @@ private void initialize() {
secondTypeChoiceBox.getItems().addAll("秒", "毫秒");
secondTypeChoiceBox.setValue("秒");
+ timeOperationType.getItems().addAll("向后", "向前");
+ timeOperationType.setValue("向后");
String language = Locale.getDefault().toLanguageTag();
@@ -245,6 +248,31 @@ private void onTimeToTimestamp() {
}
}
+ @FXML
+ private void onTimeOperate() {
+ int selectedIndex = timeOperationType.getSelectionModel().getSelectedIndex();
+ if (timeTextField2.getText().isEmpty())
+ if (!timeTextField1.getText().isEmpty())
+ this.onTimestampToTime();
+ else {
+ MessageBox.error("时间为空", "请填写时间或时间戳");
+ return;
+ }
+
+ String time = timeTextField2.getText();
+ TimeOperationType type = TimeOperationType.valueOf(selectedIndex);
+ String year = timeTextField3.getText();
+ String month = timeTextField4.getText();
+ String day = timeTextField5.getText();
+ String hour = timeTextField6.getText();
+ String minute = timeTextField7.getText();
+ String second = timeTextField8.getText();
+
+ String res = timeService.timeOperate(type, time, year, month, day, hour, minute, second);
+ timeTextField2.setText(res);
+ this.onTimeToTimestamp();
+ }
+
@FXML
private void onEncodeText() {
String originalText = decodingText.getText();
diff --git a/src/main/java/com/zzhow/magicencoding/enums/TimeOperationType.java b/src/main/java/com/zzhow/magicencoding/enums/TimeOperationType.java
new file mode 100644
index 0000000..34b453c
--- /dev/null
+++ b/src/main/java/com/zzhow/magicencoding/enums/TimeOperationType.java
@@ -0,0 +1,27 @@
+package com.zzhow.magicencoding.enums;
+
+/**
+ * @author ZZHow
+ * @date 2024/9/12
+ */
+public enum TimeOperationType {
+ FORWARD(0), BACKWARD(1);
+
+ private final int value;
+
+ private TimeOperationType(int value) {
+ this.value = value;
+ }
+
+ public int value() {
+ return this.value;
+ }
+
+ public static TimeOperationType valueOf(int value) {
+ return switch (value) {
+ case 0 -> FORWARD;
+ case 1 -> BACKWARD;
+ default -> null;
+ };
+ }
+}
diff --git a/src/main/java/com/zzhow/magicencoding/service/TimeService.java b/src/main/java/com/zzhow/magicencoding/service/TimeService.java
index 7a49460..7d3f4ef 100644
--- a/src/main/java/com/zzhow/magicencoding/service/TimeService.java
+++ b/src/main/java/com/zzhow/magicencoding/service/TimeService.java
@@ -1,5 +1,7 @@
package com.zzhow.magicencoding.service;
+import com.zzhow.magicencoding.enums.TimeOperationType;
+
import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;
@@ -25,4 +27,18 @@ public interface TimeService {
*/
public String timeToTimestamp(LocalDateTime time, TimeUnit unit);
+ /**
+ * 时间操作
+ *
+ * @param time 待操作的时间
+ * @param year 年
+ * @param month 月
+ * @param day 日
+ * @param hour 时
+ * @param minute 分
+ * @param second 秒
+ * @return 操作后的时间
+ */
+ public String timeOperate(TimeOperationType type, String time, String year, String month, String day, String hour, String minute, String second);
+
}
diff --git a/src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java b/src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java
index ed3579f..53cafbd 100644
--- a/src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java
+++ b/src/main/java/com/zzhow/magicencoding/service/impl/TimeServiceImpl.java
@@ -1,5 +1,6 @@
package com.zzhow.magicencoding.service.impl;
+import com.zzhow.magicencoding.enums.TimeOperationType;
import com.zzhow.magicencoding.service.TimeService;
import com.zzhow.magicencoding.utils.MyTimeUtil;
@@ -38,4 +39,61 @@ public String timeToTimestamp(LocalDateTime time, TimeUnit unit) {
return String.valueOf(unit == TimeUnit.SECONDS ? timestamp / 1000 : timestamp);
}
+
+ @Override
+ public String timeOperate(TimeOperationType type, String time, String year, String month, String day, String hour, String minute, String second) {
+ LocalDateTime localDateTime = null;
+ try {
+ localDateTime = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ return null;
+ }
+ long yearLong = 0;
+ long monthLong = 0;
+ long dayLong = 0;
+ long hourLong = 0;
+ long minuteLong = 0;
+ long secondLong = 0;
+
+ if (year != null && !year.isEmpty())
+ try {
+ yearLong = Long.parseLong(year);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ if (month != null && !month.isEmpty())
+ try {
+ monthLong = Long.parseLong(month);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ if (day != null && !day.isEmpty())
+ try {
+ dayLong = Long.parseLong(day);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ if (hour != null && !hour.isEmpty())
+ try {
+ hourLong = Long.parseLong(hour);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ if (minute != null && !minute.isEmpty())
+ try {
+ minuteLong = Long.parseLong(minute);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ if (second != null && !second.isEmpty())
+ try {
+ secondLong = Long.parseLong(second);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ LocalDateTime res = MyTimeUtil.timeOperate(type, localDateTime, yearLong, monthLong, dayLong, hourLong, minuteLong, secondLong);
+
+ return res.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ }
}
diff --git a/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java b/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
index 958f3f9..f8af5ee 100644
--- a/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
+++ b/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
@@ -1,8 +1,11 @@
package com.zzhow.magicencoding.utils;
+import com.zzhow.magicencoding.enums.TimeOperationType;
+
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
/**
* @author ZZHow
@@ -20,4 +23,24 @@ public static long localDateTimeToTimestamp(LocalDateTime localDateTime) {
return localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
+ public static LocalDateTime timeOperate(TimeOperationType type, LocalDateTime localDateTime, long year, long month, long day, long hour, long minute, long second) {
+ if (type == TimeOperationType.FORWARD) {
+ localDateTime = localDateTime.plusYears(year);
+ localDateTime = localDateTime.plusMonths(month);
+ localDateTime = localDateTime.plusDays(day);
+ localDateTime = localDateTime.plusHours(hour);
+ localDateTime = localDateTime.plusMinutes(minute);
+ localDateTime = localDateTime.plusSeconds(second);
+ } else {
+ localDateTime = localDateTime.minusYears(year);
+ localDateTime = localDateTime.minusMonths(month);
+ localDateTime = localDateTime.minusDays(day);
+ localDateTime = localDateTime.minusHours(hour);
+ localDateTime = localDateTime.minusMinutes(minute);
+ localDateTime = localDateTime.minusSeconds(second);
+ }
+
+ return localDateTime;
+ }
+
}
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index dcde699..fd03c2c 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -14,9 +14,10 @@
-
+
-
+
@@ -24,28 +25,44 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -56,21 +73,31 @@
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -79,43 +106,71 @@
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
@@ -124,10 +179,11 @@
-
-
-
-
+
+
+
+
From fafdd8cd813fafb0e68d2632aac5f3de4ce6bdce Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Thu, 12 Sep 2024 23:19:28 +0800
Subject: [PATCH 11/24] refactor: Adjust time manipulation logic
---
.../com/zzhow/magicencoding/controller/MainController.java | 4 ++--
src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index d794f8a..c696738 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -139,8 +139,8 @@ private void initialize() {
secondTypeChoiceBox.getItems().addAll("秒", "毫秒");
secondTypeChoiceBox.setValue("秒");
- timeOperationType.getItems().addAll("向后", "向前");
- timeOperationType.setValue("向后");
+ timeOperationType.getItems().addAll("向前", "向后");
+ timeOperationType.setValue("向前");
String language = Locale.getDefault().toLanguageTag();
diff --git a/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java b/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
index f8af5ee..9660489 100644
--- a/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
+++ b/src/main/java/com/zzhow/magicencoding/utils/MyTimeUtil.java
@@ -24,7 +24,7 @@ public static long localDateTimeToTimestamp(LocalDateTime localDateTime) {
}
public static LocalDateTime timeOperate(TimeOperationType type, LocalDateTime localDateTime, long year, long month, long day, long hour, long minute, long second) {
- if (type == TimeOperationType.FORWARD) {
+ if (type == TimeOperationType.BACKWARD) {
localDateTime = localDateTime.plusYears(year);
localDateTime = localDateTime.plusMonths(month);
localDateTime = localDateTime.plusDays(day);
From cf570779a2accee2b0828b69f63059af1d9af867 Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Fri, 13 Sep 2024 09:28:15 +0800
Subject: [PATCH 12/24] feat: Add multilingual support for the main interface
- Simplified/Traditional Chinese, English
---
.../controller/MainController.java | 67 ++++++++++++++++--
.../resources/MessagesBundle_en_US.properties | 25 ++++++-
.../resources/MessagesBundle_zh_CN.properties | 25 ++++++-
.../resources/MessagesBundle_zh_TW.properties | 25 ++++++-
.../com/zzhow/magicencoding/ui/main-view.fxml | 69 ++++++++++---------
5 files changed, 167 insertions(+), 44 deletions(-)
diff --git a/src/main/java/com/zzhow/magicencoding/controller/MainController.java b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
index c696738..a4f01ed 100644
--- a/src/main/java/com/zzhow/magicencoding/controller/MainController.java
+++ b/src/main/java/com/zzhow/magicencoding/controller/MainController.java
@@ -20,8 +20,6 @@
import javafx.scene.input.DragEvent;
import javafx.scene.input.TransferMode;
-import java.awt.*;
-import java.awt.datatransfer.StringSelection;
import java.io.*;
import java.nio.charset.Charset;
import java.time.LocalDateTime;
@@ -115,6 +113,40 @@ public class MainController {
private ChoiceBox secondTypeChoiceBox;
@FXML
private ChoiceBox timeOperationType;
+ @FXML
+ private Tab tab1;
+ @FXML
+ private Tab tab2;
+ @FXML
+ private Tab tab3;
+ @FXML
+ private Button textReset;
+ @FXML
+ private Label timeLabel1;
+ @FXML
+ private Label timeLabel2;
+ @FXML
+ private Label timeLabel3;
+ @FXML
+ private Label timeLabel4;
+ @FXML
+ private Label timeLabel5;
+ @FXML
+ private Label timeLabel6;
+ @FXML
+ private Label timeLabel7;
+ @FXML
+ private Label timeLabel8;
+ @FXML
+ private Label timeLabel9;
+ @FXML
+ private Button timeButton1;
+ @FXML
+ private Button timeButton2;
+ @FXML
+ private Button timeButton3;
+ @FXML
+ private TitledPane timeTitlePane;
public void clearFilesPath() {
@@ -377,14 +409,41 @@ private void switchLanguage() {
Label1.setText(bundle.getString("Label1"));
Label2.setText(bundle.getString("Label2"));
Label3.setText(bundle.getString("Label3"));
- Label4.setText(bundle.getString("Label4"));
+ Label4.setText(bundle.getString("charset"));
Label5.setText(bundle.getString("Label5"));
Label6.setText(bundle.getString("Label6"));
Label7.setText(bundle.getString("Label7") + fileService.getTargetFileList().size());
- Button1.setText(bundle.getString("Button1"));
+ Button1.setText(bundle.getString("reset"));
Button2.setText(bundle.getString("Button2"));
Button3.setText(bundle.getString("Button3"));
Button4.setText(bundle.getString("Button4"));
isOverwriteCheckBox.setText(bundle.getString("isOverwriteCheckBox"));
+ tab1.setText(bundle.getString("tab1"));
+ tab2.setText(bundle.getString("tab2"));
+ tab3.setText(bundle.getString("tab3"));
+ urlCharsetText.setText(bundle.getString("charset"));
+ textReset.setText(bundle.getString("reset"));
+ decodingText.setPromptText(bundle.getString("text_content"));
+ timeLabel1.setText(bundle.getString("timeLabel1"));
+ timeLabel2.setText(bundle.getString("timeLabel2"));
+ timeLabel3.setText(bundle.getString("timeLabel3"));
+ timeLabel4.setText(bundle.getString("year"));
+ timeLabel5.setText(bundle.getString("month"));
+ timeLabel6.setText(bundle.getString("day"));
+ timeLabel7.setText(bundle.getString("hour"));
+ timeLabel8.setText(bundle.getString("minute"));
+ timeLabel9.setText(bundle.getString("second"));
+ timeButton1.setText(bundle.getString("refresh"));
+ timeButton2.setText(bundle.getString("reset"));
+ timeButton3.setText(bundle.getString("operate"));
+ timeTitlePane.setText(bundle.getString("quick_operations"));
+ int selectedIndex = secondTypeChoiceBox.getSelectionModel().getSelectedIndex();
+ secondTypeChoiceBox.getItems().removeIf(item -> true);
+ secondTypeChoiceBox.getItems().addAll(bundle.getString("second"), bundle.getString("millisecond"));
+ secondTypeChoiceBox.getSelectionModel().select(selectedIndex);
+ selectedIndex = timeOperationType.getSelectionModel().getSelectedIndex();
+ timeOperationType.getItems().removeIf(item -> true);
+ timeOperationType.getItems().addAll(bundle.getString("move_forward"), bundle.getString("move_backward"));
+ timeOperationType.getSelectionModel().select(selectedIndex);
}
}
\ No newline at end of file
diff --git a/src/main/resources/MessagesBundle_en_US.properties b/src/main/resources/MessagesBundle_en_US.properties
index 7c259ac..25b43ee 100644
--- a/src/main/resources/MessagesBundle_en_US.properties
+++ b/src/main/resources/MessagesBundle_en_US.properties
@@ -1,11 +1,11 @@
Label1=Drag the folder or file to the gray area to get the path. Multiple suffixes can be separated by &
Label2=Folder / File:
Label3=Suffix:
-Label4=Character set:
+charset=Character set:
Label5=\u2192
Label6=Hit files:
Label7=Number of files:
-Button1=Reset
+reset=Reset
Button2=Find files
Button3=Start conversion
Button4=About
@@ -22,4 +22,23 @@ success1_headerText=Execution Success
success1_contentText=, number of files:
MagicEncoding=MagicEncoding 3.0.0
features=Features:
-features_content=1. Automatically identify encoding.\n2. Single file conversion.\n3. Support multiple languages.\n\t- Chinese (Simplified / Traditional)\n\t- English
\ No newline at end of file
+features_content=1. Automatically identify encoding.\n2. Single file conversion.\n3. Support multiple languages.\n\t- Chinese (Simplified / Traditional)\n\t- English
+tab1=Character file
+tab2=Character text
+tab3=Unix timestamp
+text_content=Text content
+timeLabel1=Now (seconds):
+timeLabel2=Now (milliseconds):
+timeLabel3=Timestamp:
+year=year(s)
+month=month(s)
+day=day(s)
+hour=hour(s)
+minute=minute(s)
+second=second(s)
+refresh=Refresh
+operate=Operate
+quick_operations=Quick operations
+millisecond=Millisecond
+move_forward=Move forward
+move_backward=Move backward
\ No newline at end of file
diff --git a/src/main/resources/MessagesBundle_zh_CN.properties b/src/main/resources/MessagesBundle_zh_CN.properties
index 497c2b3..6c024bf 100644
--- a/src/main/resources/MessagesBundle_zh_CN.properties
+++ b/src/main/resources/MessagesBundle_zh_CN.properties
@@ -1,11 +1,11 @@
Label1=\u5c06\u6587\u4ef6\u5939\u6216\u6587\u4ef6\u62d6\u62fd\u81f3\u7070\u8272\u533a\u57df\u4ee5\u83b7\u53d6\u8def\u5f84\uff0c\u591a\u4e2a\u540e\u7f00\u540d\u53ef\u7528\u0026\u5206\u9694
Label2=\u6587\u4ef6\u5939\u0020\u002f\u0020\u6587\u4ef6\uff1a
Label3=\u540e\u7f00\u540d\uff1a
-Label4=\u5b57\u7b26\u96c6\uff1a
+charset=\u5b57\u7b26\u96c6\uff1a
Label5=\u2192
Label6=\u547d\u4e2d\u7684\u6587\u4ef6\uff1a
Label7=\u6587\u4ef6\u6570\u76ee\uff1a
-Button1=\u91cd\u7f6e
+reset=\u91cd\u7f6e
Button2=\u67e5\u627e\u6587\u4ef6
Button3=\u5f00\u59cb\u8f6c\u6362
Button4=\u5173\u4e8e
@@ -22,4 +22,23 @@ success1_headerText=\u6267\u884c\u6210\u529f
success1_contentText=\uff0c\u6587\u4ef6\u6570\u76ee\uff1a
MagicEncoding=\u795e\u5947\u7f16\u7801\u0020\u0033\u002e\u0030\u002e\u0030\u000d\u004d\u0061\u0067\u0069\u0063\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u0020\u0033\u002e\u0030\u002e\u0030
features=\u65b0\u7279\u6027\uff1a
-features_content=\u0031\u002e\u0020\u81ea\u52a8\u8bc6\u522b\u7f16\u7801\u3002\u000d\u0032\u002e\u0020\u5355\u6587\u4ef6\u8f6c\u6362\u3002\u000d\u0033\u002e\u0020\u652f\u6301\u591a\u8bed\u8a00\u3002\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u4e2d\u6587\uff08\u7b80\u4f53\u0020\u002f\u0020\u7e41\u4f53\uff09\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u82f1\u6587
\ No newline at end of file
+features_content=\u0031\u002e\u0020\u81ea\u52a8\u8bc6\u522b\u7f16\u7801\u3002\u000d\u0032\u002e\u0020\u5355\u6587\u4ef6\u8f6c\u6362\u3002\u000d\u0033\u002e\u0020\u652f\u6301\u591a\u8bed\u8a00\u3002\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u4e2d\u6587\uff08\u7b80\u4f53\u0020\u002f\u0020\u7e41\u4f53\uff09\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u82f1\u6587
+tab1=\u5b57\u7b26\u6587\u4ef6
+tab2=\u5b57\u7b26\u6587\u672c
+tab3=Unix\u65f6\u95f4\u6233
+text_content=\u6587\u672c\u5185\u5bb9
+timeLabel1=\u73b0\u5728\uff08\u79d2\uff09\uff1a
+timeLabel2=\u73b0\u5728\uff08\u6beb\u79d2\uff09\uff1a
+timeLabel3=\u65f6\u95f4\u6233\uff1a
+year=\u5e74
+month=\u6708
+day=\u65e5
+hour=\u65f6
+minute=\u5206
+second=\u79d2
+refresh=\u5237\u65b0
+operate=\u64cd\u4f5c
+quick_operations=\u5feb\u6377\u64cd\u4f5c
+millisecond=\u6beb\u79d2
+move_forward=\u5411\u524d
+move_backward=\u5411\u540e
\ No newline at end of file
diff --git a/src/main/resources/MessagesBundle_zh_TW.properties b/src/main/resources/MessagesBundle_zh_TW.properties
index a739e07..bf9be66 100644
--- a/src/main/resources/MessagesBundle_zh_TW.properties
+++ b/src/main/resources/MessagesBundle_zh_TW.properties
@@ -1,11 +1,11 @@
Label1=\u5c07\u8cc7\u6599\u593e\u6216\u6a94\u6848\u62d6\u66f3\u81f3\u7070\u8272\u5340\u57df\u4ee5\u53d6\u5f97\u8def\u5f91\uff0c\u591a\u500b\u5f8c\u7db4\u540d\u53ef\u7528\u0026\u5206\u9694
Label2=\u8cc7\u6599\u593e\u0020\u002f\u0020\u6a94\u6848\uff1a
Label3=\u5f8c\u7db4\u540d\uff1a
-Label4=\u5b57\u5143\u96c6\uff1a
+charset=\u5b57\u5143\u96c6\uff1a
Label5=\u2192
Label6=\u547d\u4e2d\u7684\u6a94\u6848\uff1a
Label7=\u6a94\u6848\u6578\u76ee\uff1a
-Button1=\u91cd\u7f6e
+reset=\u91cd\u7f6e
Button2=\u67e5\u627e\u6a94\u6848
Button3=\u958b\u59cb\u8f49\u63db
Button4=\u95dc\u65bc
@@ -22,4 +22,23 @@ success1_headerText=\u57f7\u884c\u6210\u529f
success1_contentText=\uff0c\u6a94\u6848\u6578\u76ee\uff1a
MagicEncoding=\u795e\u5947\u7de8\u78bc\u0020\u0033\u002e\u0030\u002e\u0030\u000d\u004d\u0061\u0067\u0069\u0063\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u0020\u0033\u002e\u0030\u002e\u0030
features=\u65b0\u7279\u6027\uff1a
-features_content=\u0031\u002e\u0020\u81ea\u52d5\u8fa8\u8b58\u7de8\u78bc\u3002\u000d\u0032\u002e\u0020\u55ae\u4e00\u6a94\u6848\u8f49\u63db\u3002\u000d\u0033\u002e\u0020\u652f\u63f4\u591a\u8a9e\u8a00\u3002\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u4e2d\u6587\uff08\u7c21\u9ad4\u0020\u002f\u0020\u7e41\u9ad4\uff09\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u82f1\u6587
\ No newline at end of file
+features_content=\u0031\u002e\u0020\u81ea\u52d5\u8fa8\u8b58\u7de8\u78bc\u3002\u000d\u0032\u002e\u0020\u55ae\u4e00\u6a94\u6848\u8f49\u63db\u3002\u000d\u0033\u002e\u0020\u652f\u63f4\u591a\u8a9e\u8a00\u3002\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u4e2d\u6587\uff08\u7c21\u9ad4\u0020\u002f\u0020\u7e41\u9ad4\uff09\u000d\u0020\u0020\u0020\u0020\u002d\u0020\u82f1\u6587
+tab1=\u5b57\u5143\u6a94\u6848
+tab2=\u5b57\u5143\u6587\u5b57
+tab3=Unix\u6642\u9593\u6233
+text_content=\u6587\u5b57\u5167\u5bb9
+timeLabel1=\u73fe\u5728\uff08\u79d2\uff09\uff1a
+timeLabel2=\u73fe\u5728\uff08\u6beb\u79d2\uff09\uff1a
+timeLabel3=\u6642\u9593\u6233\uff1a
+year=\u5e74
+month=\u6708
+day=\u65e5
+hour=\u6642
+minute=\u5206
+second=\u79d2
+refresh=\u91cd\u65b0\u6574\u7406
+operate=\u64cd\u4f5c
+quick_operations=\u5feb\u901f\u64cd\u4f5c
+millisecond=\u6beb\u79d2
+move_forward=\u5411\u524d
+move_backward=\u5411\u5f8c
\ No newline at end of file
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index fd03c2c..f720146 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -21,7 +21,7 @@
-
+
@@ -69,7 +69,7 @@
-
+
@@ -92,11 +92,11 @@
-
-
@@ -104,13 +104,13 @@
-
+
-
+
-
+
-
+
@@ -141,35 +141,42 @@
prefHeight="26.0" prefWidth="88.0"/>
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
From f69868f58efe68cfec5403ed8485de34a760c8d3 Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Fri, 13 Sep 2024 09:42:12 +0800
Subject: [PATCH 13/24] feat: Enable automatic line wrapping in text boxes
- Character text module
---
src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
index f720146..6ee5c74 100644
--- a/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
+++ b/src/main/resources/com/zzhow/magicencoding/ui/main-view.fxml
@@ -84,9 +84,9 @@
style="-fx-background-color: rgba(0, 0, 0, 0.1);">
+ promptText="文本内容" wrapText="true"/>
+ promptText="Unicode" wrapText="true"/>
From af373606202a138f2475142e703f5f5a2cefd516 Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Sat, 14 Sep 2024 15:47:11 +0800
Subject: [PATCH 23/24] docs: Revise README in English
---
README.md | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index f0b8395..87f9062 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,12 @@ https://github.com/ZZHow1024/MagicEncoding/releases
---
+## What is it?
+
+MagicEncoding is a cross-platform encoding processing tool that supports character set conversion of character files, encoding and decoding of character text (Unicode and URL) and Unix timestamps (conversion between timestamps and time and shortcut operations on time).
+
+---
+
## License
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
@@ -26,6 +32,8 @@ This project is licensed under the GNU General Public License v3.0 - see the [LI
## **Instructions for use**
+Download address: https://github.com/ZZHow1024/MagicEncoding/releases
+
- Determine the operating system you are using.
- Linux:
- Select .deb installation package/ .rpm installation package.
@@ -65,7 +73,23 @@ This project is licensed under the GNU General Public License v3.0 - see the [LI
---
-## Function Introduction
+## Supported file character sets
+
+- Supported file character sets for conversion: Big5, Big5-HKSCS, CESU-8, EUC-JP, EUC-KR, GB18030, GB2312, GBK, IBM-Thai, IBM00858, IBM01140, IBM01141, IBM01142, IBM01143, IBM01144, IBM01145, IBM01146, IBM01147, IBM01148, IBM01149, IBM037, IBM1026, IBM1047, IBM273, IBM277, IBM278, IBM280, IBM284, IBM285, IBM290, IBM297, IBM420, IBM424, IBM437, IBM500, IBM775, IBM850, IBM852, IBM855, IBM857, IBM860, IBM861, IBM862, IBM863, IBM864, IBM865, IBM866, IBM868, IBM869, IBM870, IBM871, IBM918, ISO-2022-CN, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-KR, ISO-8859-1, ISO-8859-13, ISO-8859-15, ISO-8859-16, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, JIS_X0201, JIS_X0212-1990, KOI8-R, KOI8-U, Shift_JIS, TIS-620, US-ASCII, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, UTF-8, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, windows-31j, x-Big5-HKSCS-2001, x-Big5-Solaris, x-euc-jp-linux, x-EUC-TW, x-eucJP-Open, x-IBM1006, x-IBM1025, x-IBM1046, x-IBM1097, x-IBM1098, x-IBM1112, x-IBM1122, x-IBM1123, x-IBM1124, x-IBM1129, x-IBM1166, x-IBM1364, x-IBM1381, x-IBM1383, x-IBM29626C, x-IBM300, x-IBM33722, x-IBM737, x-IBM833, x-IBM834, x-IBM856, x-IBM874, x-IBM875, x-IBM921, x-IBM922, x-IBM930, x-IBM933, x-IBM935, x-IBM937, x-IBM939, x-IBM942, x-IBM942C, x-IBM943, x-IBM943C, x-IBM948, x-IBM949, x-IBM949C, x-IBM950, x-IBM964, x-IBM970, x-ISCII91, x-ISO-2022-CN-CNS, x-ISO-2022-CN-GB, x-iso-8859-11, x-JIS0208, x-JISAutoDetect, x-Johab, x-MacArabic, x-MacCentralEurope, x-MacCroatian, x-MacCyrillic, x-MacDingbat, x-MacGreek, x-MacHebrew, x-MacIceland, x-MacRoman, x-MacRomania, x-MacSymbol, x-MacThai, x-MacTurkish, x-MacUkraine, x-MS932_0213, x-MS950-HKSCS, x-MS950-HKSCS-XP, x-mswin-936, x-PCK, x-SJIS_0213, x-UTF-16LE-BOM, X-UTF-32BE-BOM, X-UTF-32LE-BOM, x-windows-50220, x-windows-50221, x-windows-874, x-windows-949, x-windows-950, x-windows-iso2022jp.
+- Supports automatic identification of file character sets:[Encodings that can be detected](https://github.com/albfernandez/juniversalchardet?tab=readme-ov-file#encodings-that-can-be-detected).
+
+---
+
+## Dependencies
+
+This project requires the following libraries:
+
+- [**juniversalchardet**](https://github.com/albfernandez/juniversalchardet): Used for character encoding detection.
+- [**OpenJFX**](https://openjfx.io/): JavaFX library for building the graphical user interface.
+
+---
+
+## Functional introduction of each version
- MagicEncoding4.0.0
- Unicode encoding and decoding of character text.
@@ -90,7 +114,7 @@ This project is licensed under the GNU General Public License v3.0 - see the [LI
---
-## **Renderings**
+## Main interface of each version

From f758465898694c39515b8068fcecc8c15c33ddda Mon Sep 17 00:00:00 2001
From: ZZHow <109335896+ZZHow1024@users.noreply.github.com>
Date: Sat, 14 Sep 2024 15:54:05 +0800
Subject: [PATCH 24/24] docs: Revise README in Chinese
---
README_ZH.md | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/README_ZH.md b/README_ZH.md
index 62b1e63..2495c7d 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -18,14 +18,22 @@ https://github.com/ZZHow1024/MagicEncoding/releases
---
-## License
+## 它是什么?
-This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
+MagicEncoding 是一款跨平台的编码处理工具,支持字符文件的字符集转换、字符文本的编解码(Unicode 与 URL)和 Unix 时间戳(时间戳与时间相互转换 和 时间的快捷操作)。
+
+---
+
+## 许可证
+
+该项目根据 GNU 通用公共许可证 v3.0 获得许可 - 有关详细信息,请参阅 [LICENSE](LICENSE) 文件。
---
## 使用说明
+下载地址:https://github.com/ZZHow1024/MagicEncoding/releases
+
- 确定您使用的操作系统。
- Linux:
- 选择 .deb安装包 / .rpm安装包。
@@ -65,7 +73,23 @@ This project is licensed under the GNU General Public License v3.0 - see the [LI
---
-## 功能介绍
+## 支持的文件字符集
+
+- 支持转换的文件字符集:Big5,Big5-HKSCS,CESU-8,EUC-JP,EUC-KR,GB18030,GB2312,GBK,IBM-Thai,IBM00858,IBM01140,IBM01141,IBM01142,IBM01143,IBM01144,IBM01145,IBM01146,IBM01147,IBM01148,IBM01149,IBM037,IBM1026,IBM1047,IBM273,IBM277,IBM278,IBM280,IBM284,IBM285,IBM290,IBM297,IBM420,IBM424,IBM437,IBM500,IBM775,IBM850,IBM852,IBM855,IBM857,IBM860,IBM861,IBM862,IBM863,IBM864,IBM865,IBM866,IBM868,IBM869,IBM870,IBM871,IBM918,ISO-2022-CN,ISO-2022-JP,ISO-2022-JP-2,ISO-2022-KR,ISO-8859-1,ISO-8859-13,ISO-8859-15,ISO-8859-16,ISO-8859-2,ISO-8859-3,ISO-8859-4,ISO-8859-5,ISO-8859-6,ISO-8859-7,ISO-8859-8,ISO-8859-9,JIS_X0201,JIS_X0212-1990,KOI8-R,KOI8-U,Shift_JIS,TIS-620,US-ASCII,UTF-16,UTF-16BE,UTF-16LE,UTF-32,UTF-32BE,UTF-32LE,UTF-8,windows-1250,windows-1251,windows-1252,windows-1253,windows-1254,windows-1255,windows-1256,windows-1257,windows-1258,windows-31j,x-Big5-HKSCS-2001,x-Big5-Solaris,x-euc-jp-linux,x-EUC-TW,x-eucJP-Open,x-IBM1006,x-IBM1025,x-IBM1046,x-IBM1097,x-IBM1098,x-IBM1112,x-IBM1122,x-IBM1123,x-IBM1124,x-IBM1129,x-IBM1166,x-IBM1364,x-IBM1381,x-IBM1383,x-IBM29626C,x-IBM300,x-IBM33722,x-IBM737,x-IBM833,x-IBM834,x-IBM856,x-IBM874,x-IBM875,x-IBM921,x-IBM922,x-IBM930,x-IBM933,x-IBM935,x-IBM937,x-IBM939,x-IBM942,x-IBM942C,x-IBM943,x-IBM943C,x-IBM948,x-IBM949,x-IBM949C,x-IBM950,x-IBM964,x-IBM970,x-ISCII91,x-ISO-2022-CN-CNS,x-ISO-2022-CN-GB,x-iso-8859-11,x-JIS0208,x-JISAutoDetect,x-Johab,x-MacArabic,x-MacCentralEurope,x-MacCroatian,x-MacCyrillic,x-MacDingbat,x-MacGreek,x-MacHebrew,x-MacIceland,x-MacRoman,x-MacRomania,x-MacSymbol,x-MacThai,x-MacTurkish,x-MacUkraine,x-MS932_0213,x-MS950-HKSCS,x-MS950-HKSCS-XP,x-mswin-936,x-PCK,x-SJIS_0213,x-UTF-16LE-BOM,X-UTF-32BE-BOM,X-UTF-32LE-BOM,x-windows-50220,x-windows-50221,x-windows-874,x-windows-949,x-windows-950,x-windows-iso2022jp。
+- 支持自动识别的文件字符集:[Encodings that can be detected](https://github.com/albfernandez/juniversalchardet?tab=readme-ov-file#encodings-that-can-be-detected)。
+
+---
+
+## 依赖项
+
+该项目需要以下库:
+
+- [**juniversalchardet**](https://github.com/albfernandez/juniversalchardet):用于字符编码检测。
+- [**OpenJFX**](https://openjfx.io/):用于构建图形用户界面的 JavaFX 库。
+
+---
+
+## 各版本功能介绍
- MagicEncoding4.0.0
- 字符文本的 Unicode 编解码。
@@ -90,7 +114,7 @@ This project is licensed under the GNU General Public License v3.0 - see the [LI
---
-## **效果图**
+## 各版本主界面
