diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index bfa274b71..9495ec706 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -1,4 +1,4 @@ -๏ปฟ[Notepad3] +[Notepad3] ;Notepad3.ini=%USERPROFILE%\Notepad3.ini ;Notepad3.ini=%APPDATA%\Rizonesoft\Notepad3\Notepad3.ini [Settings] @@ -49,7 +49,7 @@ SettingsVersion=4 ;UndoTransactionTimeout=0 ;AdministrationTool.exe= ;DevDebugMode=0 -;AnalyzeReliableConfidenceLevel=50 +;AnalyzeReliableConfidenceLevel=66 ;LexerSQLNumberSignAsComment=1 ;ExitOnESCSkipLevel=2 [Statusbar Settings] diff --git a/Versions/build.txt b/Versions/build.txt index b7749b784..45df99dca 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2706 +2707 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 90fb9c0e2..4a12b8570 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 BETA diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index f4ec82568..bd1d3f4d4 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -780,7 +780,7 @@ void LoadSettings() Settings2.NoCutLineOnEmptySelection = IniSectionGetBool(Settings2_Section, L"NoCutLineOnEmptySelection", Defaults2.NoCutLineOnEmptySelection); - int const iARCLdef = 50; + int const iARCLdef = 66; Defaults2.AnalyzeReliableConfidenceLevel = (float)iARCLdef / 100.0f; int const iARCLset = clampi(IniSectionGetInt(Settings2_Section, L"AnalyzeReliableConfidenceLevel", iARCLdef), 0, 100); Settings2.AnalyzeReliableConfidenceLevel = (float)iARCLset / 100.0f; diff --git a/src/Edit.c b/src/Edit.c index a6c9289f2..72991ba98 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1147,20 +1147,14 @@ bool EditLoadFile( } else // === ALL OTHERS === { - // ---------------------------------------------------------------------- - status->iEncoding = encDetection.Encoding; - // ---------------------------------------------------------------------- - - UINT const uCodePage = Encoding_GetCodePage(status->iEncoding); - // === UTF-8 ? === bool const bForcedUTF8 = Encoding_IsUTF8(encDetection.forcedEncoding);// ~ don't || encDetection.bIsUTF8Sig here ! - bool const bAnalysisUTF8 = Encoding_IsUTF8(encDetection.analyzedEncoding) && encDetection.bIsAnalysisReliable; - bool const bSoftHintUTF8 = Encoding_IsUTF8(encDetection.analyzedEncoding) && Encoding_IsUTF8(encDetection.Encoding); // non-reliable analysis = soft-hint + bool const bAnalysisUTF8 = Encoding_IsUTF8(encDetection.Encoding); bool const bRejectUTF8 = (IS_ENC_ENFORCED() && !bForcedUTF8) || !bValidUTF8 || (!encDetection.bIsUTF8Sig && bSkipUTFDetection); + bool const bIsCP_UTF7 = (Encoding_GetCodePage(encDetection.Encoding) == CP_UTF7); - if (bForcedUTF8 || (!bRejectUTF8 && (encDetection.bIsUTF8Sig || bAnalysisUTF8 || bSoftHintUTF8))) // soft-hint = prefer UTF-8 + if (bForcedUTF8 || (!bRejectUTF8 && (encDetection.bIsUTF8Sig || bAnalysisUTF8))) { if (encDetection.bIsUTF8Sig) { EditSetNewText(hwnd, UTF8StringStart(lpData), cbData - 3, bClearUndoHistory); @@ -1173,7 +1167,7 @@ bool EditLoadFile( EditDetectEOLMode(lpData, cbData, status); } } - else if ((uCodePage == CP_UTF7) && IsValidUTF7(lpData, cbData)) + else if (bIsCP_UTF7 && IsValidUTF7(lpData, cbData)) { // load UTF-7/ASCII(7-bit) as ANSI/UTF-8 EditSetNewText(hwnd, lpData, cbData, bClearUndoHistory); @@ -1182,6 +1176,9 @@ bool EditLoadFile( } else { // === ALL OTHER NON UTF-8 === + status->iEncoding = encDetection.Encoding; + UINT const uCodePage = Encoding_GetCodePage(encDetection.Encoding); + if (Encoding_IsEXTERNAL_8BIT(status->iEncoding)) { LPWSTR lpDataWide = AllocMem(cbData * 2 + 16, HEAP_ZERO_MEMORY); diff --git a/src/EncodingDetection.cpp b/src/EncodingDetection.cpp index a19421bc5..5514065d0 100644 --- a/src/EncodingDetection.cpp +++ b/src/EncodingDetection.cpp @@ -928,7 +928,7 @@ static void _SetEncodingTitleInfo(const char* encodingUCD, cpi_enc_t encUCD, flo //~ StringCchCatA(chEncodingInfo, ARRAYSIZE(chEncodingInfo), "'"); //~} - StringCchPrintfA(tmpBuf, ARRAYSIZE(tmpBuf), (int)lroundf(ucd_conf_perc) >= Settings2.AnalyzeReliableConfidenceLevel ? " (reliable)" : " (NOT reliable)"); + StringCchPrintfA(tmpBuf, ARRAYSIZE(tmpBuf), ucd_confidence >= Settings2.AnalyzeReliableConfidenceLevel ? " (reliable)" : " (NOT reliable)"); StringCchCatA(chEncodingInfo, ARRAYSIZE(chEncodingInfo), tmpBuf); ::MultiByteToWideChar(CP_UTF7, 0, chEncodingInfo, -1, wchEncodingInfo, ARRAYSIZE(wchEncodingInfo)); @@ -1265,6 +1265,8 @@ extern "C" ENC_DET_T Encoding_DetectEncoding(LPWSTR pszFile, const char* lpData, float confidence = 0.0f; + cpi_enc_t const asciiEnc = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT; + if (!IS_ENC_ENFORCED() || bForceEncDetection) { if (!bSkipANSICPDetection) @@ -1275,7 +1277,7 @@ extern "C" ENC_DET_T Encoding_DetectEncoding(LPWSTR pszFile, const char* lpData, if (encDetRes.analyzedEncoding == CPI_NONE) { encDetRes.analyzedEncoding = iAnalyzeFallback; - confidence = Settings2.AnalyzeReliableConfidenceLevel; + confidence = Settings2.AnalyzeReliableConfidenceLevel / 4.0f; } if (!bSkipUTFDetection) @@ -1303,7 +1305,7 @@ extern "C" ENC_DET_T Encoding_DetectEncoding(LPWSTR pszFile, const char* lpData, if (bForceEncDetection) { if (Encoding_IsValid(encDetRes.analyzedEncoding)) { // no bIsReliable check (forced unreliable detection) - encDetRes.forcedEncoding = (encDetRes.analyzedEncoding == CPI_ASCII_7BIT) ? CPI_ANSI_DEFAULT : encDetRes.analyzedEncoding; + encDetRes.forcedEncoding = (encDetRes.analyzedEncoding == CPI_ASCII_7BIT) ? asciiEnc : encDetRes.analyzedEncoding; } else if (Encoding_IsValid(encDetRes.unicodeAnalysis)) { encDetRes.forcedEncoding = encDetRes.unicodeAnalysis; @@ -1318,11 +1320,10 @@ extern "C" ENC_DET_T Encoding_DetectEncoding(LPWSTR pszFile, const char* lpData, if (encDetRes.analyzedEncoding == CPI_NONE) { encDetRes.analyzedEncoding = iAnalyzeFallback; - confidence = Settings2.AnalyzeReliableConfidenceLevel; + confidence = Settings2.AnalyzeReliableConfidenceLevel / 4.0f; } else if (encDetRes.analyzedEncoding == CPI_ASCII_7BIT) { - encDetRes.analyzedEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT; - confidence = 1.0; + encDetRes.analyzedEncoding = asciiEnc; } } @@ -1333,16 +1334,12 @@ extern "C" ENC_DET_T Encoding_DetectEncoding(LPWSTR pszFile, const char* lpData, // -------------------------------------------------------------------------- // init Preferred Encoding - encDetRes.Encoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT; + encDetRes.Encoding = asciiEnc; if (IS_ENC_ENFORCED()) { encDetRes.Encoding = encDetRes.forcedEncoding; } - else if (Encoding_IsValid(encDetRes.analyzedEncoding) && (encDetRes.bIsAnalysisReliable || !Settings.UseReliableCEDonly)) - { - encDetRes.Encoding = encDetRes.analyzedEncoding; - } else if (encDetRes.bIsUTF8Sig) { encDetRes.Encoding = CPI_UTF8SIGN; @@ -1351,11 +1348,20 @@ extern "C" ENC_DET_T Encoding_DetectEncoding(LPWSTR pszFile, const char* lpData, encDetRes.Encoding = bBOM_LE ? CPI_UNICODEBOM : CPI_UNICODEBEBOM; encDetRes.bIsReverse = bBOM_BE; } + else if (Encoding_IsValid(encDetRes.analyzedEncoding) && (encDetRes.bIsAnalysisReliable || !Settings.UseReliableCEDonly)) + { + encDetRes.Encoding = encDetRes.analyzedEncoding; + } else if (Encoding_IsValid(Encoding_SrcWeak(CPI_GET))) { encDetRes.Encoding = Encoding_SrcWeak(CPI_GET); + encDetRes.bIsAnalysisReliable = false; + } + else if (Encoding_IsValid(iAnalyzeFallback)) { + encDetRes.Encoding = iAnalyzeFallback; + encDetRes.bIsAnalysisReliable = false; } - if (!Encoding_IsValid(encDetRes.Encoding)) { encDetRes.Encoding = CPI_ANSI_DEFAULT; } + if (!Encoding_IsValid(encDetRes.Encoding)) { encDetRes.Encoding = asciiEnc; } return encDetRes; } diff --git a/src/VersionEx.h b/src/VersionEx.h index e88c4b45d..384eb1729 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -9,7 +9,7 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 20 #define VERSION_REV 114 -#define VERSION_BUILD 2706 +#define VERSION_BUILD 2707 #define SCINTILLA_VER 423 #define ONIGURUMA_REGEX_VER 6.9.4 #define UCHARDET_VER 2018.09.27 diff --git a/test/test_files/encoding/Txtfiles/Thai.txt b/test/test_files/encoding/Txtfiles/Thai.txt new file mode 100644 index 000000000..642550955 --- /dev/null +++ b/test/test_files/encoding/Txtfiles/Thai.txt @@ -0,0 +1,21 @@ +ข้อ มนุษย์ทั้งหลายเกิดมามีอิสระและเสมอภาคกันในเกียรติศักด[เกียรติศักดิ์]และสิทธิ +ต่างมีเหตุผลและมโนธรรม และควรปฏิบัติต่อกันด้วยเจตนารมณ์แห่งภราดรภาพ + +ข้อ ทุกคนย่อมมีสิทธิและอิสรภาพบรรดาที่กำหนดไว้ในปฏิญญานี้ + โดยปราศจากความแตกต่างไม่ว่าชนิดใด ๆ ดังเช่น เชื้อชาติ ผิว เพศ ภาษา ศาสนา + ความคิดเห็นทางการเมืองหรือทางอื่น เผ่าพันธุ์แห่งชาติ หรือสังคม ทรัพย์สิน กำเนิด หรือสถานะอื่น ๆ + อนึ่งจะไม่มีความแตกต่างใด ๆ ตามมูลฐานแห่งสถานะทางการเมือง ทางการศาล หรือทางการระหว่างประเทศของประเทศหรือดินแดนที่บุคคลสังกัด + ไม่ว่าดินแดนนี้จะเป็นเอกราช อยู่ในความพิทักษ์มิได้ปกครองตนเอง หรืออยู่ภายใต้การจำกัดอธิปไตยใด ๆ ทั้งสิ้น + + ข้อ ทุกคนย่อมมีสิทธิและอิสรภาพบรรดาที่กำหนดไว้ในปฏิญญานี้ + โดยปราศจากความแตกต่างไม่ว่าชนิดใด ๆ ดังเช่น เชื้อชาติ ผิว เพศ ภาษา ศาสนา + ความคิดเห็นทางการเมืองหรือทางอื่น เผ่าพันธุ์แห่งชาติ หรือสังคม ทรัพย์สิน กำเนิด หรือสถานะอื่น ๆ + อนึ่งจะไม่มีความแตกต่างใด ๆ ตามมูลฐานแห่งสถานะทางการเมือง ทางการศาล หรือทางการระหว่างประเทศของประเทศหรือดินแดนที่บุคคลสังกัด + ไม่ว่าดินแดนนี้จะเป็นเอกราช อยู่ในความพิทักษ์มิได้ปกครองตนเอง หรืออยู่ภายใต้การจำกัดอธิปไตยใด ๆ ทั้งสิ้น + + ข้อ ทุกคนย่อมมีสิทธิและอิสรภาพบรรดาที่กำหนดไว้ในปฏิญญานี้ + โดยปราศจากความแตกต่างไม่ว่าชนิดใด ๆ ดังเช่น เชื้อชาติ ผิว เพศ ภาษา ศาสนา + ความคิดเห็นทางการเมืองหรือทางอื่น เผ่าพันธุ์แห่งชาติ หรือสังคม ทรัพย์สิน กำเนิด หรือสถานะอื่น ๆ + อนึ่งจะไม่มีความแตกต่างใด ๆ ตามมูลฐานแห่งสถานะทางการเมือง ทางการศาล หรือทางการระหว่างประเทศของประเทศหรือดินแดนที่บุคคลสังกัด + ไม่ว่าดินแดนนี้จะเป็นเอกราช อยู่ในความพิทักษ์มิได้ปกครองตนเอง หรืออยู่ภายใต้การจำกัดอธิปไตยใด ๆ ทั้งสิ้น + \ No newline at end of file diff --git a/test/test_files/encoding/Txtfiles/apache notes.txt b/test/test_files/encoding/Txtfiles/apache notes.txt new file mode 100644 index 000000000..2e369bc56 --- /dev/null +++ b/test/test_files/encoding/Txtfiles/apache notes.txt @@ -0,0 +1,31 @@ +Apache on Windows: +================== +รฉ + +* Which distribution? + +apache.org no longer provides Windows binaries. They direct you to other sources. + +Candidates: + - The Apache Haus (apachehaus.com) + - Apache Lounge (apachelounge.com) + +My current favourite is Apache Lounge. Use the distro with the highest Visual C version you can, and that matches the target system architecture. + +Prerequisite: Visual C++ Redistributable + + +* Updating: + +(Also check for the latest Visual C++ Redistributable) + +Prรฉcis: + +- Build a new folder at same level as production folder, with "_new" suffix +- Copy as much production data as possible to new folder +- Stop (old) production +- Copy remainder of production data to new folder, moving what can't be copied because of space constraints +- Rename production folder to backup folder (becomes backup) +- Rename new folder to production folder (becomes production) +- Start (new) production and test +