From a0f1e0e9db4b0edee45018c47a08761916af0ce6 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 7 Jun 2008 20:40:48 +0200 Subject: Revised UTF-8 filenames support --- UViewer.pas | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'UViewer.pas') 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 -- cgit v1.2.3