Параметры процедуры:
Код:
FmtStr(var StrResult: string; const Format: string; const Args: array of string);
Строка с ошибкой:
Код:
FmtStr(Result, '%s%.6x', ['#', Color]);
Result имеет тип WideString.
Я не знаю что это, но нигде не регистрируется:
Больше кода(вся функция из файла
SciScintilla.res с проблемной строкой она тут
25я):
Код:
procedure TScintilla.ExportToHTML(Stream: TStream; Title: WideString; UseCurrentEOLMode: Boolean; CSSStream: TStream; CSSFileName: WideString);
Var
StyleIsUsed: array [0 .. STYLE_MAX + 1] of Boolean;
lang: TSciLangItem;
eolstr: WideString;
usecss: Boolean;
procedure WriteS(const S: WideString);
begin
Stream.Write(S[1], length(S));
end;
procedure WriteCSS(const S: WideString);
begin
if usecss = true then
CSSStream.Write(S[1], length(S))
else
Stream.Write(S[1], length(S))
end;
function ColorToHTMLColor(Color: TColor): WideString;
var
TempS: WideString;
begin
if Color < 0 then
Color := ColorToRGB(Color);
FmtStr(Result, '%s%.6x', ['#', Color]);
// Now swap Blue and Red
TempS := Result;
Result[2] := TempS[6];
Result[3] := TempS[7];
Result[6] := TempS[2];
Result[7] := TempS[3];
end;
procedure WriteStyle(const Style: TSciStyle);
begin
with Style do
begin
if not StyleIsUsed[StyleNumber] then
Exit;
WriteCSS('.S' + IntToStr(StyleNumber) + ' {' + eolstr);
if FontName <> '' then
WriteCSS(#9'font-family:' + FontName + ';' + eolstr);
if FontSize <> 0 then
WriteCSS(#9'font-size:' + IntToStr(FontSize) + 'pt' + ';' + eolstr);
if fsItalic in FontStyles then
WriteCSS(#9'font-style: italic;' + eolstr)
else
WriteCSS(#9'font-style: normal;' + eolstr);
if fsBold in FontStyles then
WriteCSS(#9'font-weight: 700;' + eolstr)
else
WriteCSS(#9'font-weight: 400;' + eolstr);
if fsUnderline in FontStyles then
WriteCSS(#9'text-decoration:underline;' + eolstr)
else
WriteCSS(#9'text-decoration:none;' + eolstr);
if ForeColor <> clDefault then
WriteCSS(#9'color: ' + ColorToHTMLColor(ForeColor) + ';' + eolstr);
if BackColor <> clDefault then
WriteCSS(#9'background: ' + ColorToHTMLColor(BackColor) + ';' + eolstr);
WriteCSS('}' + eolstr);
end;
end;
Var
i, itab, TabSize, Style, StyleCurrent, LengthDoc: Integer;
ch: WideChar;
begin
usecss := false;
if not Assigned(fLanguageManager) then
raise Exception.CreateRes(@eNoLanguageManager);
if Assigned(CSSStream) and (CSSFileName <> '') then
usecss := true;
if UseCurrentEOLMode = true then
begin
case EOLStyle of
eolCRLF:
eolstr := CrLf;
eolCR:
eolstr := #13;
eolLF:
eolstr := #10;
end;
end
else
eolstr := CrLf;
Colourise(0, -1);
TabSize := TabWidth;
if TabSize = 0 then
TabSize := 4;
lang := fLanguageManager.LanguageList.FindLang(fSelectedLanguage);
LengthDoc := GetLength;
for i := 0 to STYLE_MAX + 1 do
StyleIsUsed[i] := false;
// check the used styles
for i := 0 to LengthDoc do
StyleIsUsed[GetStyleAt(i)] := true;
StyleIsUsed[STYLE_DEFAULT] := true;
WriteS('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' + eolstr);
WriteS('<html xmlns="http://www.w3.org/1999/xhtml">' + eolstr);
WriteS('<head>' + eolstr);
WriteS('<title>' + Title + '</title>' + eolstr);
WriteS('<meta name="GENERATOR" content="Delphi Scintilla Interface Components - delphisci.sourceforge.net"/>' + eolstr);
if CodePage = SC_CP_UTF8 then
WriteS(
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>' +
eolstr);
if (usecss = false) then
WriteS('<style type="text/css">' + eolstr);
WriteCSS('body {background: ' + ColorToHTMLColor(Color) + ';}');
// Write default style
WriteCSS('span {' + eolstr);
WriteCSS(#9'font-family:' + Font.Name + ';' + eolstr);
WriteCSS(#9'font-size:' + ToStr(Font.Size) + 'pt' + ';' + eolstr);
if fsItalic in Font.Style then
WriteCSS(#9'font-style: italic;' + eolstr)
else
WriteCSS(#9'font-style: normal;' + eolstr);
if fsBold in Font.Style then
WriteCSS(#9'font-weight: 700;' + eolstr)
else
WriteCSS(#9'font-weight: 400;' + eolstr);
if fsUnderline in Font.Style then
WriteCSS(#9'text-decoration:underline;' + eolstr)
else
WriteCSS(#9'text-decoration:none;' + eolstr);
WriteCSS(#9'color: ' + ColorToHTMLColor(Font.Color) + ';' + eolstr);
WriteCSS(#9'background: ' + ColorToHTMLColor(Color) + ';' + eolstr);
WriteCSS('}' + eolstr);
// Write all styles
for i := 0 to lang.Styles.Count - 1 do
WriteStyle(lang.Styles.Items[i] as TSciStyle);
if usecss = false then
WriteS('</style>' + eolstr)
else
WriteS('<link rel="StyleSheet" href="' + ExtractFileName(CSSFileName)
+ '" type="text/css"/>');
WriteS('</head>' + eolstr);
WriteS('<body><div class="mainbody">' + eolstr);
StyleCurrent := GetStyleAt(0);
WriteS('<span>');
WriteS('<span class="S' + ToStr(StyleCurrent) + '">');
for i := 0 to LengthDoc - 1 do
begin
ch := Char(GetCharAt(i) and $FF);
Style := GetStyleAt(i);
if Style <> StyleCurrent then
begin
WriteS('</span>');
StyleCurrent := Style; // moved this before the <span writing.. Didn't write the correct style otherwise.
WriteS('<span class="S' + ToStr(StyleCurrent) + '">');
end;
Case Ord(ch) of
Ord(' '):
begin
if (Char(GetCharAt(i + 1) and $FF) <> ' ') or (i + 1 >= LengthDoc)
then
// Single space, kept as is
WriteS(' ')
else
WriteS(' ');
end;
$9: // Tab
for itab := 1 to TabSize do
WriteS(' ');
$D, $A:
begin
if not((ch = #13) and (GetCharAt(i + 1) = $A)) then
begin
WriteS('<br/>');
WriteS('</span>');
StyleCurrent := GetStyleAt(i + 1);
WriteS(eolstr);
// we know it's the correct next style
WriteS('<span class="S' + IntToStr(StyleCurrent) + '">');
end;
end;
Ord('<'):
WriteS('<');
Ord('>'):
WriteS('>');
Ord('&'):
WriteS('&');
Ord('"'):
WriteS('"');
Ord('ж'):
WriteS('æ');
Ord('Ж'):
WriteS('Æ');
Ord('ш'):
WriteS('ø');
Ord('Ш'):
WriteS('Ø');
Ord('е'):
WriteS('å');
Ord('Е'):
WriteS('Å');
else
WriteS(ch);
end;
end;
WriteS('</span>');
WriteS('</span>');
WriteS(eolstr + '</div></body>' + eolstr + '</html>' + eolstr);
end;