From ff91aa43a3241b27593e8951d4404ddfd9e8a30e Mon Sep 17 00:00:00 2001 From: nnn-revo2012 Date: Wed, 30 Aug 2023 22:22:56 +0900 Subject: [PATCH] =?UTF-8?q?Ver=200.0.1.23=20Update=20README.txt=20-=20?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E7=A8=AE=E5=88=A5=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E6=8B=A1=E5=BC=B5=E5=AD=90=E3=81=8C=E5=A4=A7?= =?UTF-8?q?=E6=96=87=E5=AD=97=E3=81=A7=E3=82=82=E5=88=A4=E5=AE=9A=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3=20-=20=E3=82=B5?= =?UTF-8?q?=E3=83=AD=E3=82=B2=E3=83=BC=E3=83=88=E3=83=9A=E3=82=A2=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20=20=20=E7=95=B0=E4=BD=93=E5=AD=97=E3=82=BB=E3=83=AC?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E5=89=8A=E9=99=A4(=E3=81=95=E3=81=8D?= =?UTF-8?q?=E3=82=85=E3=81=B0=E3=81=99=E3=81=AE=E5=90=8C=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E3=81=A8=E5=90=8C=E7=AD=89=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.txt | 10 +++++++++- comeconv/Prop/Version.cs | 4 ++-- comeconv/Util/Utils.cs | 37 +++++++++++++++++++++++++++---------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/README.txt b/README.txt index 4b8a3d3..0719b59 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ =============================================================================== 【タイトル】 comeconv 【ファイル】 comeconv.exe -【作成月日】 2023/04/30 +【作成月日】 2023/08/30 【著 作 者】 nnn-revo2012 【開発環境】 Microsoft Windows 10 Microsoft Visual Studio Community 2019 @@ -253,4 +253,12 @@ GNU General Public License v3.0 Twitch変換機能追加 - yt-dlp(Youtube)の --write-subs に対応 Json.NET 13.0.3 のDLLが更新されていなかったので追加 +2023/08/30 Version 0.0.1.23 + - ファイル種別判定で拡張子が大文字でも判定するよう修正 + - サロゲートペア削除メソッドを修正 + 異体字セレクタ削除(さきゅばすの同メソッドと同等に修正) + Twitch変換機能修正 + - yt-dlp(Youtube)のコメント変換時に常にYoutubeカスタム絵文字が:aaaaaaaaa: のように表示されるのを修正 + リファクタリング + - 不要な変数と未使用のメソッド削除 diff --git a/comeconv/Prop/Version.cs b/comeconv/Prop/Version.cs index b9d45fd..e62cb8a 100644 --- a/comeconv/Prop/Version.cs +++ b/comeconv/Prop/Version.cs @@ -4,8 +4,8 @@ namespace comeconv.Prop { public class Ver { - public static readonly string Version = "0.0.1.22"; - public static readonly string VerDate = "2023/04/30"; + public static readonly string Version = "0.0.1.23"; + public static readonly string VerDate = "2023/08/30"; public static string GetFullVersion() { diff --git a/comeconv/Util/Utils.cs b/comeconv/Util/Utils.cs index 7865628..f5e8eec 100644 --- a/comeconv/Util/Utils.cs +++ b/comeconv/Util/Utils.cs @@ -23,21 +23,38 @@ public class Utils //サロゲートペア&結合文字 検出&文字除去 //\ud83d\ude0a //か\u3099 + //異体字セレクタ U+FE00~U+FE0F、U+E0100〜U+E01EF は削除 + //サロゲートペア文字は t で置換 public static string DelEmoji(string s, string t = "") { - if (!IsSurrogatePair(s)) return s; + if (s.Length <= 0) return s; StringBuilder sb = new StringBuilder(); - TextElementEnumerator tee = StringInfo.GetTextElementEnumerator(s); - - tee.Reset(); - while (tee.MoveNext()) + for (int i = 0; i < s.Length; i++) { - string te = tee.GetTextElement(); - if (Char.IsSurrogate(te[0])) - sb.Append(t); //サロゲートペアまたは結合文字の場合 + char c = s[i]; + if (c >= (char)0xFE00 && c <= (char)0xFE0F) + { + continue; + } + else if (Char.IsHighSurrogate(c)) + { + if (c == (char)0xdb40) + { + char cc = s[i + 1]; + if (cc >= (char)0xdd00 && cc <= (char)0xddef) + { + ++i; + continue; + } + } + sb.Append(t); + ++i; + } else - sb.Append(te); + { + sb.Append(c); + } } return sb.ToString(); } @@ -112,7 +129,7 @@ public static int IsFileType(string filename) { var result = -1; - var ext = Path.GetExtension(filename); + var ext = Path.GetExtension(filename).ToLower(); if (ext == ".xml" || ext == ".json" || ext == ".jsonl" || ext == ".txt") result = 0; else if (ext == ".ts" || ext == ".flv" || ext == ".mp4")