• R/O
  • SSH
  • HTTPS

ktx: Commit


Commit MetaInfo

Revision36 (tree)
Zeit2019-11-03 16:30:34
Autorbananajinn

Log Message

・コマンドライン引数でパスを渡した時にも文字コード自動判別する
・文字コード自動判別が間違っていたのを修正

Ändern Zusammenfassung

Diff

--- trunk/ktx/Program.cs (revision 35)
+++ trunk/ktx/Program.cs (revision 36)
@@ -25,7 +25,7 @@
2525 var mf = new MainForm();
2626 mf.Show();
2727 if(args.Length > 0){
28- int cp = 65001;
28+ int cp = 0;
2929 string path = null;
3030 foreach(var arg in args){
3131 var m = Regex.Match(arg, "[/-]cp([0-9]+)");
@@ -37,7 +37,7 @@
3737 }
3838 }
3939 if(path != null){
40- mf.FileEncoding = Encoding.GetEncoding(cp);
40+ mf.FileEncoding = cp == 0 ? FileEncodingDetector.GetEncoding(path) : Encoding.GetEncoding(cp);
4141 mf.Path = path;
4242 }
4343 }
--- trunk/ktx/Utils/FileEncodingDetector.cs (revision 35)
+++ trunk/ktx/Utils/FileEncodingDetector.cs (revision 36)
@@ -76,16 +76,13 @@
7676 } else if ((b & 0xf0) == 0xe0) {
7777 /* 3 bytes */
7878 charLen = 3;
79- continue;
80- }
81- if ((b & 0xf8) == 0xf0) {
79+ } else if ((b & 0xf8) == 0xf0) {
8280 /* 4 bytes */
8381 charLen = 4;
84- continue;
8582 }
8683 if (charLen == 0)
8784 return false;
88- for (int j = 0; j < charLen && i + j < length; j++) {
85+ for (int j = 1; j < charLen && i + j < length; j++) {
8986 if (!Is2ndByteOfUTF8(buffer[i + j]))
9087 return false;
9188 }
Show on old repository browser