summaryrefslogtreecommitdiff
path: root/UViewer.pas
diff options
context:
space:
mode:
Diffstat (limited to 'UViewer.pas')
-rw-r--r--UViewer.pas14
1 files changed, 9 insertions, 5 deletions
diff --git a/UViewer.pas b/UViewer.pas
index d7d1c4c..70d3a64 100644
--- a/UViewer.pas
+++ b/UViewer.pas
@@ -393,19 +393,23 @@ begin
Valid := True;
for i := 0 to LineBuffer.Count - 1 do begin
- Valid := Valid and g_utf8_validate(PChar(LineBuffer[i]), -1, nil);
- if not Valid then Break;
+ Valid := Valid and g_utf8_validate(PChar(LineBuffer[i]), Length(LineBuffer[i]), nil);
+ if not Valid then begin
+ DebugMsg(['** TFViewer.LoadFile(', FileName, ', Line ', i + 1, ') is not UTF-8 valid.']);
+ Break;
+ end;
end;
-
+
if Valid then TextView.Lines.SetText(LineBuffer.Text)
- else
+ else begin
for i := 0 to LineBuffer.Count - 1 do
TextView.Lines.InsertText(AnsiToUtf8(LineBuffer[i]) + #10);
+ end;
{ LineHeight := 16;
NumLines := LineBuffer.Count; }
- Caption := Format('TuxView [%s]', [ANSIToUTF8(FileName)]);
+ Caption := Format('TuxView [%s]', [StrToUTF8(FileName)]);
// FDrawingArea.SetSizeRequest(-1, NumLines * LineHeight);
Result := True;
except