@@ -2479,15 +2479,15 @@ void frmStatus::addLogFile(const wxString &filename, const wxDateTime timestamp,
2479
2479
// changed to return the csv format log files, we should handle it.
2480
2480
2481
2481
bool csv_log_format = filename.Right (4 ) == wxT (" .csv" );
2482
-
2482
+
2483
2483
if (csv_log_format && savedPartialLine.length () > 0 )
2484
2484
{
2485
2485
if (read == 0 ) // Starting at beginning of log file
2486
2486
savedPartialLine.clear ();
2487
2487
else
2488
2488
line = savedPartialLine;
2489
2489
}
2490
- wxString funcname = " pg_read_file (" ;
2490
+ wxString funcname = " pg_read_binary_file (" ;
2491
2491
if (!settings->GetASUTPstyle ()) funcname = " pg_file_read(" ;
2492
2492
while (len > read )
2493
2493
{
@@ -2499,24 +2499,73 @@ void frmStatus::addLogFile(const wxString &filename, const wxDateTime timestamp,
2499
2499
connection->IsAlive ();
2500
2500
return ;
2501
2501
}
2502
- char *raw = set->GetCharPtr (0 );
2502
+
2503
+ char *raw1 = set->GetCharPtr (0 );
2503
2504
2504
- if (!raw || !*raw )
2505
+ if (!raw1 || !*raw1 )
2505
2506
{
2506
2507
delete set;
2507
2508
break ;
2508
2509
}
2509
-
2510
- read += strlen (raw);
2511
-
2512
- wxString str;
2513
- str = line + wxTextBuffer::Translate (wxString (raw, set->GetConversion ()), wxTextFileType_Unix);
2514
- // if (wxString(wxString(raw, wxConvLibc).wx_str(), wxConvUTF8).Len() > 0)
2515
- // str = line + wxString(wxString(raw, wxConvLibc).wx_str(), wxConvUTF8);
2516
- // else {
2517
- // str = line + wxTextBuffer::Translate(wxString(raw, set->GetConversion()), wxTextFileType_Unix);
2518
- // }
2510
+ char * raw;
2511
+ unsigned char m[50001 ];
2512
+ if (settings->GetASUTPstyle ()) {
2519
2513
2514
+ raw =( char *) &m[0 ];
2515
+ unsigned char c;
2516
+ unsigned char * startChar;
2517
+ int pos = 0 ;
2518
+ raw1 = raw1 + 2 ;
2519
+ int utf8charLen = 0 ;
2520
+ while (*raw1!=0 ) {
2521
+ c = *raw1;
2522
+ c = c - ' 0' ;
2523
+ if (c > 9 ) c = *raw1 - ' a' + 10 ;
2524
+ raw1++;
2525
+ m[pos] = c << 4 ;
2526
+ c = *raw1 - ' 0' ;
2527
+ if (c > 9 ) c = *raw1 - ' a' + 10 ;
2528
+ c = c | m[pos];
2529
+ m[pos] = c;
2530
+ // check utf-8 char
2531
+ if (utf8charLen == 0 ) {
2532
+ startChar = &m[pos];
2533
+ if (c >> 7 == 0 )
2534
+ utf8charLen = 1 ;
2535
+ else if (c >> 5 == 0x6 )
2536
+ utf8charLen = 2 ;
2537
+ else if (c >> 4 == 0xE )
2538
+ utf8charLen = 3 ;
2539
+ else if (c >> 5 == 0x1E )
2540
+ utf8charLen = 4 ;
2541
+ else
2542
+ utf8charLen=0 ;
2543
+ // bad utf8 format
2544
+ }
2545
+ pos++;
2546
+ raw1++;
2547
+ utf8charLen--;
2548
+ }
2549
+ //
2550
+ if (utf8charLen != 0 ) {
2551
+ // read = startChar - &m[0];
2552
+ // remove bad utf-8 char
2553
+ *startChar = 0 ;
2554
+ } else
2555
+ m[pos] = 0 ;
2556
+ } else {
2557
+ raw = raw1;
2558
+ }
2559
+ read += strlen (raw);
2560
+
2561
+ wxString str;
2562
+ str = line + wxTextBuffer::Translate (wxString (raw, set->GetConversion ()), wxTextFileType_Unix);
2563
+ // if (wxString(wxString(raw, wxConvLibc).wx_str(), wxConvUTF8).Len() > 0)
2564
+ // str = line + wxString(wxString(raw, wxConvLibc).wx_str(), wxConvUTF8);
2565
+ // else {
2566
+ // str = line + wxTextBuffer::Translate(wxString(raw, set->GetConversion()), wxTextFileType_Unix);
2567
+ // }
2568
+
2520
2569
2521
2570
delete set;
2522
2571
0 commit comments