• R/O
  • SSH
  • HTTPS

ktx: Commit


Commit MetaInfo

Revision41 (tree)
Time2022-11-16 17:29:09
Authorbananajinn

Log Message

文字コード判別処理でBOMの判定が間違えていたのを修正

Change Summary

Incremental Difference

--- trunk/ktx/Utils/FileEncodingDetector.cs (revision 40)
+++ trunk/ktx/Utils/FileEncodingDetector.cs (revision 41)
@@ -37,6 +37,8 @@
3737 {
3838 var bytes = new byte[length];
3939 Array.Copy(buffer, bytes, length);
40+ if (EqualsBytes(bytes, 0xff, 0xfe, 0x00, 0x00))
41+ return Encoding.UTF32;
4042 if (EqualsBytes(bytes, 0xfe, 0xff))
4143 return Encoding.BigEndianUnicode;
4244 if (EqualsBytes(bytes, 0xff, 0xfe))
@@ -43,15 +45,13 @@
4345 return Encoding.Unicode;
4446 if (EqualsBytes(bytes, 0xef, 0xbb, 0xbf))
4547 return Encoding.UTF8;
46- if (EqualsBytes(bytes, 0xff, 0xfe, 0x00, 0x00))
47- return Encoding.UTF32;
4848 return null;
4949 }
5050
5151 private static bool EqualsBytes(byte[] a, params byte[] b)
5252 {
53- if (a.Length == b.Length) {
54- for (int i = 0; i < a.Length; i++) {
53+ if (a.Length >= b.Length) {
54+ for (int i = 0; i < b.Length; i++) {
5555 if (a[i] != b[i])
5656 return false;
5757 }
Show on old repository browser