Detect and process NUL characters before giving loaded SQL to SynEdit. Works around issue #1093.

This commit is contained in:
rosenfield.albert
2009-04-28 21:16:18 +00:00
parent 1d0b3d2b85
commit d25e271591
2 changed files with 35 additions and 2 deletions

View File

@ -133,8 +133,9 @@ type
function MakeFloat( Str: String ): Extended;
function FloatStr(Val: String): String;
function esc(Text: WideString; ProcessJokerChars: Boolean = false; sql_version: integer = 50000): WideString;
function hasNullChar(Text: WideString): boolean;
function ScanNulChar(Text: WideString): Boolean;
function ScanLineBreaks(Text: WideString): TLineBreaks;
function RemoveNulChars(Text: WideString): WideString;
procedure debug(txt: String);
function fixNewlines(txt: string): string;
function bool2str( boolval : Boolean ) : String;
@ -1638,8 +1639,9 @@ end;
{***
Detect NUL character in a text.
Useful because fx SynEdit cuts of all text after it encounters a NUL.
}
function hasNullChar(Text: WideString): boolean;
function ScanNulChar(Text: WideString): boolean;
var
i: integer;
begin
@ -1703,6 +1705,30 @@ end;
{***
Mangle input text so that SynEdit can load it.
@param string Text to test
@return Boolean
}
function RemoveNulChars(Text: WideString): WideString;
var
i: integer;
c: WideChar;
begin
SetLength(Result, Length(Text));
if Length(Text) = 0 then Exit;
i := 1;
repeat
c := Text[i];
if c = #0 then Result[i] := #32
else Result[i] := c;
i := i + 1;
until i > length(Text);
end;
{***
Use DebugView from SysInternals or Delphi's Event Log to view.