From 35109f800dc8fd29f4f59762842bd30252f2fc10 Mon Sep 17 00:00:00 2001
From: marco <marco@freepascal.org>
Date: Sun, 5 May 2019 15:36:41 +0000
Subject: [PATCH] # revisions: 40925

git-svn-id: branches/fixes_3_2@41999 -
---
 utils/fpdoc/dglobals.pp             |  24 ++-
 utils/fpdoc/dw_html.pp              | 315 +++++++++++++---------------
 utils/fpdoc/dw_htmlchm.inc          |  14 +-
 utils/fpdoc/dw_ipflin.pas           |  22 +-
 utils/fpdoc/dw_latex.pp             |  19 +-
 utils/fpdoc/dw_linrtf.pp            |   8 +-
 utils/fpdoc/dw_man.pp               |  15 +-
 utils/fpdoc/dw_txt.pp               |   2 +-
 utils/fpdoc/dw_xml.pp               |  66 +++---
 utils/fpdoc/dwlinear.pp             |  22 +-
 utils/fpdoc/dwriter.pp              |  23 +-
 utils/fpdoc/examples/simple/html.sh |   2 +-
 utils/fpdoc/fpclasschart.lpi        |   8 +-
 utils/fpdoc/fpdoc.pp                |   2 +-
 utils/fpdoc/fpdocclasstree.pp       |  13 +-
 utils/fpdoc/fpdocxmlopts.pas        |  51 ++---
 utils/fpdoc/makeskel.lpi            |  13 +-
 utils/fpdoc/mkfpdoc.pp              |   4 +-
 18 files changed, 298 insertions(+), 325 deletions(-)

diff --git a/utils/fpdoc/dglobals.pp b/utils/fpdoc/dglobals.pp
index 09a7531bdf..f8f672ae68 100644
--- a/utils/fpdoc/dglobals.pp
+++ b/utils/fpdoc/dglobals.pp
@@ -23,7 +23,7 @@ unit dGlobals;
 
 interface
 
-uses Classes, DOM, PasTree, PParser, StrUtils,uriparser;
+uses Classes, DOM, PasTree, PParser, uriparser;
 
 Const
   CacheSize = 20;
@@ -204,6 +204,7 @@ Const
        'Published', 'Automated','Strict Private','Strict Protected');
 
 type
+  TBufType = Array[1..ContentBufSize-1] of byte;
 
   // Assumes a list of TObject instances and frees them on destruction
 
@@ -996,9 +997,10 @@ end;
 
 var
   s: String;
-  buf : Array[1..ContentBufSize-1] of byte;
+  buf : TBufType;
 
 begin
+  buf:=Default(TBufType);
   if not FileExists(AFileName) then
     raise EInOutError.Create('File not found: ' + AFileName);
   Assign(f, AFilename);
@@ -1053,8 +1055,10 @@ var
   ClassDecl: TPasClassType;
   Member: TPasElement;
   s: String;
-  Buf : Array[0..ContentBufSize-1] of byte;
+  Buf : TBufType;
+
 begin
+  Buf:=Default(TBufType);
   Assign(ContentFile, AFilename);
   Rewrite(ContentFile);
   SetTextBuf(ContentFile,Buf,SizeOf(Buf));
@@ -1117,7 +1121,7 @@ begin
         begin
           Member := TPasElement(ClassDecl.Members[k]);
           Write(ContentFile, Chr(Ord(Member.Visibility) + Ord('0')));
-          SetLength(s, 0);
+          S:='';
           if Member.ClassType = TPasVariable then
             Write(ContentFile, 'V')
           else if Member.ClassType = TPasProperty then
@@ -1371,7 +1375,7 @@ begin
     Parser := TDOMParser.Create; // create a parser object
     try
       Src := TXMLInputSource.Create(FileStream); // and the input source
-      src.SystemId:=FileNameToUri(AFileName);
+      src.SystemId:=UTF8Decode(FileNameToUri(AFileName));
       try
         Parser.Options.PreserveWhitespace := True;
         Parser.Parse(Src, ADoc);
@@ -1396,13 +1400,13 @@ Var
     Subnode: TDOMNode;
   begin
     if OwnerDocNode = RootDocNode then
-      Result := OwnerDocNode.CreateChildren('#' + Element['name'])
+      Result := OwnerDocNode.CreateChildren('#' + UTF8Encode(Element['name']))
     else
-      Result := OwnerDocNode.CreateChildren(Element['name']);
+      Result := OwnerDocNode.CreateChildren(UTF8Encode(Element['name']));
     Result.FNode := Element;
-    Result.FLink := Element['link'];
+    Result.FLink := UTF8Encode(Element['link']);
     if (Element['alwaysvisible'] = '1') and (Element.NodeName='element') then
-      FAlwaysVisible.Add(LowerCase(PN+'.'+TDocNode(OwnerDocNode).Name+'.'+Element['name']));
+      FAlwaysVisible.Add(LowerCase(PN+'.'+TDocNode(OwnerDocNode).Name+'.'+UTF8Encode(Element['name'])));
     Result.FIsSkipped := Element['skip'] = '1';
     Subnode := Element.FirstChild;
     while Assigned(Subnode) do
@@ -1660,7 +1664,7 @@ begin
   Result:='';
   for i := 0 to DescrDocs.Count - 1 do
     begin
-    Fn:=ExElement['file'];
+    Fn:=UTF8Encode(ExElement['file']);
     if (FN<>'') and (TDOMDocument(DescrDocs[i]) = ExElement.OwnerDocument) then
       begin
       Result := ExtractFilePath(DescrDocNames[i]) + FN;
diff --git a/utils/fpdoc/dw_html.pp b/utils/fpdoc/dw_html.pp
index 29e1c0372e..df51525847 100644
--- a/utils/fpdoc/dw_html.pp
+++ b/utils/fpdoc/dw_html.pp
@@ -16,10 +16,10 @@
 {$H+}
 
 unit dw_HTML;
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
-uses Classes, contnrs, DOM, DOM_HTML, dGlobals, PasTree, dWriter, ChmWriter, ChmBase;
+uses Classes, DOM, DOM_HTML, dGlobals, PasTree, dWriter, ChmWriter;
 
 const
   // Subpage indices for modules
@@ -53,22 +53,12 @@ type
     function GetCSSFilename(ARelativeTo: TPasElement): DOMString; virtual;
   end;
 
-  TShortNameFileAllocator = class(TFileAllocator)
-  private
-    FExtension: String;
-  public
-    constructor Create(const AExtension: String);
-    procedure AllocFilename(AElement: TPasElement; ASubindex: Integer); override;
-    property Extension: String read FExtension;
-  end;
-
   TLongNameFileAllocator = class(TFileAllocator)
   private
     FExtension: String;
   public
     constructor Create(const AExtension: String);
-    function GetFilename(AElement: TPasElement;
-      ASubindex: Integer): String; override;
+    function GetFilename(AElement: TPasElement; ASubindex: Integer): String; override;
     function GetRelativePathToTop(AElement: TPasElement): String; override;
     property Extension: String read FExtension;
   end;
@@ -137,6 +127,7 @@ type
     function CreateTR(Parent: TDOMNode): THTMLElement;
     function CreateTD(Parent: TDOMNode): THTMLElement;
     function CreateTD_vtop(Parent: TDOMNode): THTMLElement;
+    function CreateLink(Parent: TDOMNode; const AHRef: String): THTMLElement;
     function CreateLink(Parent: TDOMNode; const AHRef: DOMString): THTMLElement;
     function CreateAnchor(Parent: TDOMNode; const AName: DOMString): THTMLElement;
     function CreateCode(Parent: TDOMNode): THTMLElement;
@@ -196,9 +187,11 @@ type
     procedure DescrBeginTableCell; override;
     procedure DescrEndTableCell; override;
 
+    procedure AppendText(Parent: TDOMNode; const AText: String);
     procedure AppendText(Parent: TDOMNode; const AText: DOMString);
     procedure AppendNbSp(Parent: TDOMNode; ACount: Integer);
     procedure AppendSym(Parent: TDOMNode; const AText: DOMString);
+    procedure AppendKw(Parent: TDOMNode; const AText: String);
     procedure AppendKw(Parent: TDOMNode; const AText: DOMString);
     function AppendPasSHFragment(Parent: TDOMNode; const AText: String;
       AShFlags: Byte): Byte;
@@ -207,8 +200,8 @@ type
     procedure AppendShortDescrCell(Parent: TDOMNode; Element: TPasElement);
     procedure AppendDescr(AContext: TPasElement; Parent: TDOMNode;
       DescrNode: TDOMElement; AutoInsertBlock: Boolean);
-    procedure AppendDescrSection(AContext: TPasElement; Parent: TDOMNode;
-      DescrNode: TDOMElement; const ATitle: DOMString);
+    procedure AppendDescrSection(AContext: TPasElement; Parent: TDOMNode;  DescrNode: TDOMElement; const ATitle: String);
+    procedure AppendDescrSection(AContext: TPasElement; Parent: TDOMNode;  DescrNode: TDOMElement; const ATitle: DOMString);
     function AppendHyperlink(Parent: TDOMNode; Element: TPasElement): TDOMElement;
     function AppendType(CodeEl, TableEl: TDOMElement;
       Element: TPasType; Expanded: Boolean;
@@ -221,6 +214,7 @@ type
     function AppendRecordType(CodeEl, TableEl: TDOMElement; Element: TPasRecordType; NestingLevel: Integer): TDOMElement;
     procedure CreateMemberDeclarations(AParent: TPasElement; Members: TFPList; TableEl: TDOmelement; AddEnd: Boolean);
 
+    procedure AppendTitle(const AText: String; Hints : TPasMemberHints = []);
     procedure AppendTitle(const AText: DOMString; Hints : TPasMemberHints = []);
     procedure AppendMenuBar(ASubpageIndex: Integer);
     procedure AppendTopicMenuBar(Topic : TTopicElement);
@@ -279,18 +273,13 @@ type
     Property UseMenuBrackets : Boolean Read FUseMenuBrackets write FUseMenuBrackets;
   end;
 
-  THTMWriter = class(THTMLWriter)
-  Protected
-    Procedure CreateAllocator; override;
-  end;
-
   {$DEFINE chmInterface}
   {$I dw_htmlchm.inc}
   {$UNDEF chmInterface}
 
 implementation
 
-uses SysUtils, XHTML, XMLRead, XMLWrite, HTMWrite, sh_pas, fpdocclasstree,
+uses SysUtils, XMLRead, HTMWrite, sh_pas, fpdocclasstree,
   chmsitemap;
 
 {$i css.inc}
@@ -312,27 +301,15 @@ end;
 
 function TFileAllocator.GetRelativePathToTop(AElement: TPasElement): String;
 begin
-  SetLength(Result, 0);
+  Result:='';
 end;
 
 function TFileAllocator.GetCSSFilename(ARelativeTo: TPasElement): DOMString;
 begin
-  Result := GetRelativePathToTop(ARelativeTo) + 'fpdoc.css';
+  Result := Utf8Decode(GetRelativePathToTop(ARelativeTo)) + 'fpdoc.css';
 end;
 
 
-constructor TShortNameFileAllocator.Create(const AExtension: String);
-begin
-  inherited Create;
-  FExtension := AExtension;
-end;
-
-procedure TShortNameFileAllocator.AllocFilename(AElement: TPasElement;
-  ASubindex: Integer);
-begin
-  // !!!: Add element to file list
-end;
-
 
 constructor TLongNameFileAllocator.Create(const AExtension: String);
 begin
@@ -546,7 +523,6 @@ constructor THTMLWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
   Procedure AddClassMemberPages(AModule: TPasModule; LinkList : TObjectList);
   var
     i, j, k: Integer;
-    s: String;
     ClassEl: TPasClassType;
     FPEl, AncestorMemberEl: TPasElement;
     DocNode: TDocNode;
@@ -578,7 +554,7 @@ constructor THTMLWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
         else
           ALink:='';
         If (ALink<>'') then
-          LinkList.Add(TLinkData.Create(FPEl.PathName,ALink,AModule.name))
+          LinkList.Add(TLinkData.Create(FPEl.PathName,UTF8Encode(ALink),AModule.name))
         else
           AddPage(FPEl, 0);
         end
@@ -689,7 +665,7 @@ begin
     // Resolve links
     For I:=0 to L.Count-1 do
       With TLinkData(L[i]) do
-        Engine.AddLink(FPathName,ResolveLinkIDInUnit(FLink,FModuleName));
+        Engine.AddLink(FPathName,UTF8Encode(ResolveLinkIDInUnit(FLink,FModuleName)));
   finally
     L.Free;
   end;
@@ -741,7 +717,7 @@ begin
   HeadEl.AppendChild(El);
   El['rel'] := 'stylesheet';
   El['type'] := 'text/css';
-  El['href'] := FixHtmlPath(Allocator.GetCSSFilename(AElement));
+  El['href'] := UTF8Decode(FixHtmlPath(UTF8Encode(Allocator.GetCSSFilename(AElement))));
 end;
 
 function THTMLWriter.CreateXHTMLPage(AElement: TPasElement;
@@ -941,20 +917,20 @@ end;
 function THTMLWriter.ResolveLinkID(const Name: String; Level : Integer = 0): DOMString;
 
 var
-  i: Integer;
-  ThisPackage: TLinkNode;
-  s:String;
+  res,s: String;
+
 begin
-  Result:=Engine.ResolveLink(Module,Name, True);
+  res:=Engine.ResolveLink(Module,Name, True);
   // engine can return backslashes on Windows
-  if Length(Result) > 0 then
+  if Length(res) > 0 then
    begin
-     s:=Copy(Result, 1, Length(CurDirectory) + 1);
+     s:=Copy(Res, 1, Length(CurDirectory) + 1);
     if (S= CurDirectory + '/') or (s= CurDirectory + '\') then
-      Result := Copy(Result, Length(CurDirectory) + 2, Length(Result))
-    else if not IsLinkAbsolute(Result) then
-      Result := BaseDirectory + Result;
+      Res := Copy(Res, Length(CurDirectory) + 2, Length(Res))
+    else if not IsLinkAbsolute(Res) then
+      Res := BaseDirectory + Res;
    end;
+  Result:=UTF8Decode(Res);
 end;
 
 function THTMLWriter.ResolveLinkWithinPackage(AElement: TPasElement;
@@ -1036,11 +1012,16 @@ begin
   Result['valign'] := 'top';
 end;
 
+function THTMLWriter.CreateLink(Parent: TDOMNode; const AHRef: String): THTMLElement;
+begin
+  Result := CreateEl(Parent, 'a');
+  Result['href'] := UTF8Decode(FixHtmlPath(AHRef));
+end;
+
 function THTMLWriter.CreateLink(Parent: TDOMNode;
   const AHRef: DOMString): THTMLElement;
 begin
-  Result := CreateEl(Parent, 'a');
-  Result['href'] := FixHtmlPath(AHRef);
+  Result:=CreateLink(Parent,UTF8Encode(aHREf));
 end;
 
 function THTMLWriter.CreateAnchor(Parent: TDOMNode;
@@ -1123,7 +1104,7 @@ end;
 procedure THTMLWriter.DescrWriteImageEl(const AFileName, ACaption, ALinkName : DOMString);
 
 Var
-  Pel,Cel,Lel : TDOMNode;
+  Pel,Cel: TDOMNode;
   El :TDomElement;
   D : String;
   L : Integer;
@@ -1156,11 +1137,11 @@ begin
 
   // Create image node.  
   El:=CreateEl(Pel,'img');
-  EL['src']:=D + BaseImageURL + AFileName;
+  EL['src']:=UTF8Decode(D + BaseImageURL) + AFileName;
   El['alt']:=ACaption;
 
   //cache image filename, so it can be used later (CHM)
-  FImageFileList.Add(BaseImageURL + AFileName);
+  FImageFileList.Add(UTF8Encode(UTF8Decode(BaseImageURL) + AFileName));
 end;
 
 procedure THTMLWriter.DescrWriteFileEl(const AText: DOMString);
@@ -1189,9 +1170,10 @@ end;
 procedure THTMLWriter.DescrBeginLink(const AId: DOMString);
 var
   a,s,n : String;
+
 begin
-  a:=AId;
-  s := ResolveLinkID(a);
+  a:=UTF8Encode(AId);
+  s := UTF8Encode(ResolveLinkID(a));
   if Length(s) = 0 then
   begin
     if assigned(module) then
@@ -1363,7 +1345,7 @@ var
   Table: TDOMElement;
 begin
   Table := CreateEl(CurOutputNode, 'table');
-  Table['border'] := IntToStr(Ord(HasBorder));
+  Table['border'] := UTF8Decode(IntToStr(Ord(HasBorder)));
   PushOutputNode(Table);
 end;
 
@@ -1417,6 +1399,11 @@ begin
   PopOutputNode;
 end;
 
+procedure THTMLWriter.AppendText(Parent: TDOMNode; const AText: String);
+begin
+  AppendText(Parent,UTF8Decode(aText));
+end;
+
 
 procedure THTMLWriter.AppendText(Parent: TDOMNode; const AText: DOMString);
 begin
@@ -1441,6 +1428,11 @@ begin
   AppendText(El, AText);
 end;
 
+procedure THTMLWriter.AppendKw(Parent: TDOMNode; const AText: String);
+begin
+  AppendKW(Parent,UTF8Decode(aText));
+end;
+
 procedure THTMLWriter.AppendKw(Parent: TDOMNode; const AText: DOMString);
 var
   El: TDOMElement;
@@ -1456,8 +1448,6 @@ function THTMLWriter.AppendPasSHFragment(Parent: TDOMNode;
 
 var
   Line, Last, p: PChar;
-  IsInSpecial: Boolean;
-  lastwasasm : boolean;
   El: TDOMElement;
 
   Procedure MaybeOutput;
@@ -1478,14 +1468,14 @@ var
       end;
   end;
 
-  Function NewEl(Const ElType,Attr,AttrVal : String) : TDomElement;
+  Function NewEl(Const ElType,Attr,AttrVal : DOMString) : TDomElement;
 
   begin
     Result:=CreateEl(Parent,ElType);
     Result[Attr]:=AttrVal;
   end;
 
-  Function NewSpan(Const AttrVal : String) : TDomElement;
+  Function NewSpan(Const AttrVal : DOMString) : TDomElement;
 
   begin
     Result:=CreateEl(Parent,'span');
@@ -1497,7 +1487,6 @@ begin
   Try
   DoPascalHighlighting(AShFlags, PChar(AText), Line);
   Result := AShFlags;
-  IsInSpecial := False;
   Last := Nil;
   p := Line;
   el:=nil;
@@ -1594,6 +1583,11 @@ begin
   end;
 end;
 
+procedure THTMLWriter.AppendDescrSection(AContext: TPasElement; Parent: TDOMNode; DescrNode: TDOMElement; const ATitle: String);
+begin
+  AppendDescrSection(aContext,Parent,DescrNode,UTF8Decode(aTitle));
+end;
+
 procedure THTMLWriter.AppendDescrSection(AContext: TPasElement;
   Parent: TDOMNode; DescrNode: TDOMElement; const ATitle: DOMString);
 begin
@@ -1610,7 +1604,7 @@ end;
 function THTMLWriter.AppendHyperlink(Parent: TDOMNode;
   Element: TPasElement): TDOMElement;
 var
-  s: String;
+  s: DOMString;
   UnitList: TFPList;
   i: Integer;
   ThisPackage: TLinkNode;
@@ -1924,7 +1918,7 @@ function THTMLWriter.AppendRecordType(CodeEl, TableEl: TDOMElement;
 var
   i, j: Integer;
   Variable: TPasVariable;
-  TREl, TDEl: TDOMElement;
+  TREl: TDOMElement;
   CurVariant: TPasVariant;
   isExtended : Boolean;
   VariantEl: TPasElement;
@@ -2012,11 +2006,11 @@ end;
 procedure THTMLWriter.AppendTitle(const AText: DOMString; Hints : TPasMemberHints = []);
 
 Var
-  T : String;
+  T : UnicodeString;
 begin
   T:=AText;
   if (Hints<>[]) then
-    T:=T+' ('+Engine.HintsToStr(Hints)+')';
+    T:=T+' ('+UTF8Decode(Engine.HintsToStr(Hints))+')';
   AppendText(TitleElement, AText);
   AppendText(CreateH1(BodyElement), T);
 end;
@@ -2170,9 +2164,8 @@ Procedure THTMLWriter.AppendSeeAlsoSection(AElement : TPasElement;DocNode : TDoc
 
 var
   Node: TDOMNode;
-  TableEl, El, TREl, TDEl, ParaEl, NewEl, DescrEl: TDOMElement;
-  l,s,n: String;
-  f: Text;
+  TableEl, El, TREl, ParaEl, NewEl, DescrEl: TDOMElement;
+  l,s,n: DOMString;
   IsFirstSeeAlso : Boolean;
 
 begin
@@ -2194,16 +2187,16 @@ begin
        TREl:=CreateTR(TableEl);
        ParaEl:=CreatePara(CreateTD_vtop(TREl));
        l:=El['id'];
-       s:= ResolveLinkID(l);
+       s:= ResolveLinkID(UTF8ENcode(l));
        if Length(s)=0 then
          begin
          if assigned(module) then
-           s:=module.name
+           s:=UTF8Decode(module.name)
          else
            s:='?';
          if l='' then l:='<empty>';
          if Assigned(AElement) then
-           N:=AElement.Name
+           N:=UTF8Decode(AElement.Name)
          else
            N:='?';
          DoLog(SErrUnknownLinkID, [s,N,l]);
@@ -2223,7 +2216,7 @@ begin
         else
           AppendText(NewEl,El['id']);
        l:=El['id'];
-       DescrEl := Engine.FindShortDescr(ModuleForElement(AElement),L);
+       DescrEl := Engine.FindShortDescr(ModuleForElement(AElement),UTF8Encode(L));
        if Assigned(DescrEl) then
          begin
          AppendNbSp(CreatePara(CreateTD(TREl)), 2);
@@ -2266,7 +2259,7 @@ begin
           Reset(f);
           try
             PushOutputNode(BodyElement);
-            DescrBeginCode(False, TDOMElement(Node)['highlighter']);
+            DescrBeginCode(False, UTF8Encode(TDOMElement(Node)['highlighter']));
             while not EOF(f) do
               begin
               ReadLn(f, s);
@@ -2322,15 +2315,15 @@ begin
     begin
     // Description
     if Assigned(DocNode.Descr) then
-      AppendDescrSection(AElement, BodyElement, DocNode.Descr, SDocDescription);
+      AppendDescrSection(AElement, BodyElement, DocNode.Descr, UTF8Encode(SDocDescription));
 
     // Append "Errors" section
     if Assigned(DocNode.ErrorsDoc) then
-      AppendDescrSection(AElement, BodyElement, DocNode.ErrorsDoc, SDocErrors);
+      AppendDescrSection(AElement, BodyElement, DocNode.ErrorsDoc, UTF8Encode(SDocErrors));
 
     // Append Version info
     if Assigned(DocNode.Version) then
-      AppendDescrSection(AElement, BodyElement, DocNode.Version, SDocVersion);
+      AppendDescrSection(AElement, BodyElement, DocNode.Version, UTF8Encode(SDocVersion));
 
     // Append "See also" section
     AppendSeeAlsoSection(AElement,DocNode);
@@ -2346,10 +2339,6 @@ Procedure THTMLWriter.CreateTopicPageBody(AElement : TTopicElement);
 
 var
   DocNode: TDocNode;
-  TableEl, TREl: TDOMElement;
-  I : Integer;
-  S : String;
-
 begin
   AppendTopicMenuBar(AElement);
   DocNode:=AElement.TopicNode;
@@ -2367,6 +2356,7 @@ begin
 end;
 
 procedure THTMLWriter.CreateClassHierarchyPage(AList : TStringList; AddUnit : Boolean);
+
   Procedure PushClassElement;
 
   Var
@@ -2398,13 +2388,12 @@ procedure THTMLWriter.CreateClassHierarchyPage(AList : TStringList; AddUnit : Bo
   Var
     N : TDomNode;
     P,PM : TPasElement;
-    NN : String;
     EN : String;
     LL : TstringList;
     I,J : Integer;
 
   begin
-    EN:=Package.Name+'.'+E['unit']+'.'+E.NodeName;
+    EN:=Package.Name+'.'+UTF8Encode(E['unit'])+'.'+UTF8Encode(E.NodeName);
     J:=AList.IndexOf(EN);
     If J<>-1 then
       P:=AList.Objects[J] as TPasElement
@@ -2431,7 +2420,7 @@ procedure THTMLWriter.CreateClassHierarchyPage(AList : TStringList; AddUnit : Bo
         While (N<>Nil) do
           begin
           if (N.NodeType=ELEMENT_NODE) then
-            LL.AddObject(N.NodeName,N);
+            LL.AddObject(UTF8Encode(N.NodeName),N);
           N:=N.NextSibling;
           end;
         if (LL.Count>0) then
@@ -2456,8 +2445,6 @@ procedure THTMLWriter.CreateClassHierarchyPage(AList : TStringList; AddUnit : Bo
 Var
   B : TClassTreeBuilder;
   E : TDomElement;
-  F : TFileStream;
-
 begin
   PushOutputNode(BodyElement);
   try
@@ -2495,7 +2482,6 @@ Var
   L : TStringList;
   I : Integer;
   M : TPasModule;
-  E : TPasElement;
   S : String;
   SE : THTMLElement;
 
@@ -2516,7 +2502,7 @@ begin
     S:=Package.Name;
     If Length(S)>0 then
       Delete(S,1,1);
-    AppendTitle(Format(SDocPackageClassHierarchy, [S]));
+    AppendTitle(UTF8Decode(Format(SDocPackageClassHierarchy, [S])));
     CreateClassHierarchyPage(L,True);
   Finally
     L.Free;
@@ -2578,8 +2564,6 @@ end;
 procedure THTMLWriter.CreateIndexPage(L : TStringList);
 Var
   Lists  : Array['A'..'Z'] of TStringList;
-  LOther : TStringList;
-  
   CL : TStringList;
   TableEl, TREl, EL: TDOMElement;
   E : TPasElement;
@@ -2624,7 +2608,7 @@ begin
     If (Lists[C]<>Nil) then
       begin
       El:=CreateTD_vtop(TREl);
-      AppendText(CreateLink(El,'#SECTION'+C),C);
+      AppendText(CreateLink(El,UTF8Decode('#SECTION'+C)),UTF8Decode(C));
       If C<>'Z' then
        AppendNBsp(El,1);
       end;
@@ -2636,8 +2620,8 @@ begin
     If CL<>Nil then
       begin
       El:=CreateH2(BodyElement);
-      AppendText(El,C);
-      CreateAnchor(El,'SECTION'+C);
+      AppendText(El,UTF8Decode(C));
+      CreateAnchor(El,UTF8Decode('SECTION'+C));
       TableEl := CreateTable(BodyElement);
       TableEl['Width']:='80%';
       // Determine number of rows needed
@@ -2708,8 +2692,7 @@ Var
   L : TStringList;
   I : Integer;
   M : TPasModule;
-  E : TPasElement;
-  S : String;    
+  S : String;
   
 begin
   L:=TStringList.Create;
@@ -2725,7 +2708,7 @@ begin
     S:=Package.Name;
     If Length(S)>0 then
       Delete(S,1,1);
-    AppendTitle(Format(SDocPackageIndex, [S]));
+    AppendTitle(UTF8Decode(Format(SDocPackageIndex, [S])));
     CreateIndexPage(L);
   Finally
     L.Free;
@@ -2742,10 +2725,10 @@ var
 
 begin
   AppendMenuBar(0);
-  AppendTitle(Format(SDocPackageTitle, [Copy(Package.Name, 2, 256)]));
+  AppendTitle(UTF8Encode(Format(SDocPackageTitle, [Copy(Package.Name, 2, 256)])));
   AppendShortDescr(CreatePara(BodyElement), Package);
 
-  AppendText(CreateH2(BodyElement), SDocUnits);
+  AppendText(CreateH2(BodyElement), UTF8Encode(SDocUnits));
   TableEl := CreateTable(BodyElement);
   L:=TStringList.Create;
   Try
@@ -2769,7 +2752,7 @@ begin
   if Assigned(DocNode) then
     begin
     if Assigned(DocNode.Descr) then
-       AppendDescrSection(nil, BodyElement, DocNode.Descr, SDocDescription);
+       AppendDescrSection(nil, BodyElement, DocNode.Descr, UTF8Decode(SDocDescription));
     CreateTopicLinks(DocNode,Package);
     end;
 end;
@@ -2792,7 +2775,7 @@ begin
       if first then
         begin
         First:=False;
-        AppendText(CreateH2(BodyElement), SDocRelatedTopics);
+        AppendText(CreateH2(BodyElement), UTF8Decode(SDocRelatedTopics));
         TableEl := CreateTable(BodyElement);
         end;
       TREl := CreateTR(TableEl);
@@ -2815,7 +2798,7 @@ begin
   try
     AddModuleIdentifiers(AModule,L);
     AppendMenuBar(IndexSubIndex);
-    AppendTitle(Format(SDocModuleIndex, [AModule.Name]));
+    AppendTitle(UTF8Decode(Format(SDocModuleIndex, [AModule.Name])));
     CreateIndexPage(L);
   Finally
     L.Free;
@@ -2833,7 +2816,7 @@ procedure THTMLWriter.CreateModulePageBody(AModule: TPasModule;
     DocNode: TDocNode;
   begin
     AppendMenuBar(0);
-    AppendTitle(Format(SDocUnitTitle, [AModule.Name]),AModule.Hints);
+    AppendTitle(UTF8Decode(Format(SDocUnitTitle, [AModule.Name])),AModule.Hints);
     AppendShortDescr(CreatePara(BodyElement), AModule);
 
     if AModule.InterfaceSection.UsesList.Count > 0 then
@@ -2864,7 +2847,7 @@ procedure THTMLWriter.CreateModulePageBody(AModule: TPasModule;
     if Assigned(DocNode) then
       begin
       if Assigned(DocNode.Descr) then
-        AppendDescrSection(AModule, BodyElement, DocNode.Descr, SDocOverview);
+        AppendDescrSection(AModule, BodyElement, DocNode.Descr, UTF8Decode(SDocOverview));
       ConvertNotes(AModule,DocNode.Notes);
       CreateTopicLinks(DocNode,AModule);
       end;
@@ -2872,7 +2855,7 @@ procedure THTMLWriter.CreateModulePageBody(AModule: TPasModule;
 
   procedure CreateSimpleSubpage(const ATitle: DOMString; AList: TFPList);
   var
-    TableEl, TREl, TDEl, CodeEl: TDOMElement;
+    TableEl, TREl, CodeEl: TDOMElement;
     i, j: Integer;
     Decl: TPasElement;
     SortedList: TFPList;
@@ -2881,8 +2864,8 @@ procedure THTMLWriter.CreateModulePageBody(AModule: TPasModule;
 
   begin
     AppendMenuBar(ASubpageIndex);
-    S:=ATitle;
-    AppendTitle(Format(SDocUnitTitle + ': %s', [AModule.Name, S]));
+    S:=UTF8Encode(ATitle);
+    AppendTitle(UTF8Decode(Format(SDocUnitTitle + ': %s', [AModule.Name, S])));
     SortedList := TFPList.Create;
     try
       for i := 0 to AList.Count - 1 do
@@ -2916,20 +2899,19 @@ procedure THTMLWriter.CreateModulePageBody(AModule: TPasModule;
   procedure CreateResStringsPage;
   var
     ParaEl: TDOMElement;
-    i, j: Integer;
+    i: Integer;
     Decl: TPasResString;
-    DocNode: TDocNode;
   begin
     AppendMenuBar(ResstrSubindex);
-    AppendTitle(Format(SDocUnitTitle + ': %s', [AModule.Name, SDocResStrings]));
+    AppendTitle(UTF8Decode(Format(SDocUnitTitle + ': %s', [AModule.Name, SDocResStrings])));
     for i := 0 to AModule.InterfaceSection.ResStrings.Count - 1 do
     begin
       Decl := TPasResString(AModule.InterfaceSection.ResStrings[i]);
-      CreateEl(BodyElement, 'a')['name'] := LowerCase(Decl.Name);
+      CreateEl(BodyElement, 'a')['name'] := UTF8Decode(LowerCase(Decl.Name));
       ParaEl := CreatePara(BodyElement);
-      AppendText(CreateCode(ParaEl), Decl.Name);
+      AppendText(CreateCode(ParaEl), UTF8Decode(Decl.Name));
       CreateEl(ParaEl, 'br');
-      AppendText(ParaEl, Decl.Expr.getDeclaration(true));
+      AppendText(ParaEl, UTF8Decode(Decl.Expr.getDeclaration(true)));
     end;
   end;
   
@@ -2941,15 +2923,15 @@ begin
     ResstrSubindex:
       CreateResStringsPage;
     ConstsSubindex:
-      CreateSimpleSubpage(SDocConstants, AModule.InterfaceSection.Consts);
+      CreateSimpleSubpage(UTF8Decode(SDocConstants), AModule.InterfaceSection.Consts);
     TypesSubindex:
-      CreateSimpleSubpage(SDocTypes, AModule.InterfaceSection.Types);
+      CreateSimpleSubpage(UTF8Decode(SDocTypes), AModule.InterfaceSection.Types);
     ClassesSubindex:
-      CreateSimpleSubpage(SDocClasses, AModule.InterfaceSection.Classes);
+      CreateSimpleSubpage(UTF8Decode(SDocClasses), AModule.InterfaceSection.Classes);
     ProcsSubindex:
-      CreateSimpleSubpage(SDocProceduresAndFunctions, AModule.InterfaceSection.Functions);
+      CreateSimpleSubpage(UTF8Decode(SDocProceduresAndFunctions), AModule.InterfaceSection.Functions);
     VarsSubindex:
-      CreateSimpleSubpage(SDocVariables, AModule.InterfaceSection.Variables);
+      CreateSimpleSubpage(UTF8Decode(SDocVariables), AModule.InterfaceSection.Variables);
     IndexSubIndex: 
       CreateModuleIndexPage(AModule);
   end;
@@ -2960,16 +2942,16 @@ var
   TableEl, CodeEl: TDOMElement;
 begin
   AppendMenuBar(-1);
-  AppendTitle(AConst.Name,AConst.Hints);
+  AppendTitle(UTF8Decode(AConst.Name),AConst.Hints);
   AppendShortDescr(CreatePara(BodyElement), AConst);
-  AppendText(CreateH2(BodyElement), SDocDeclaration);
+  AppendText(CreateH2(BodyElement), UTF8Decode(SDocDeclaration));
   AppendSourceRef(AConst);
 
   TableEl := CreateTable(BodyElement);
   CodeEl := CreateCode(CreatePara(CreateTD(CreateTR(TableEl))));
 
   AppendKw(CodeEl, 'const');
-  AppendText(CodeEl, ' ' + AConst.Name);
+  AppendText(CodeEl, ' ' + UTF8Decode(AConst.Name));
   if Assigned(AConst.VarType) then
   begin
     AppendSym(CodeEl, ': ');
@@ -2988,8 +2970,6 @@ Var
   s: String;
   EnumType: TPasEnumType;
   EnumValue: TPasEnumValue;
-  Variable: TPasVariable;
-
 begin
   // Alias
   if AType.ClassType = TPasAliasType then
@@ -3092,16 +3072,11 @@ procedure THTMLWriter.CreateTypePageBody(AType: TPasType);
 var
   TableEl, TREl, TDEl, CodeEl: TDOMElement;
   DocNode: TDocNode;
-  i: Integer;
-  s: String;
-  EnumType: TPasEnumType;
-  EnumValue: TPasEnumValue;
-  Variable: TPasVariable;
 begin
   AppendMenuBar(-1);
-  AppendTitle(AType.Name,AType.Hints);
+  AppendTitle(UTF8Decode(AType.Name),AType.Hints);
   AppendShortDescr(CreatePara(BodyElement), AType);
-  AppendText(CreateH2(BodyElement), SDocDeclaration);
+  AppendText(CreateH2(BodyElement), UTF8Decode(SDocDeclaration));
   AppendSourceRef(AType);
 
   TableEl := CreateTable(BodyElement);
@@ -3111,13 +3086,13 @@ begin
 
   DocNode := Engine.FindDocNode(AType);
   AppendKw(CodeEl, 'type ');
-  AppendText(CodeEl, AType.Name);
+  AppendText(CodeEl, UTF8Decode(AType.Name));
   AppendSym(CodeEl, ' = ');
 
   If Assigned(DocNode) and
      Assigned(DocNode.Node) and
      (Docnode.Node['opaque']='1') then
-    AppendText(CodeEl,SDocOpaque)
+    AppendText(CodeEl,UTF8Decode(SDocOpaque))
   else
     begin
     AppendTypeDecl(AType,TableEl,CodeEl);
@@ -3178,7 +3153,7 @@ begin
         begin
         CurVisibility := MVisibility;
         s:=VisibilityNames[MVisibility];
-        AppendKw(CreateCode(CreatePara(CreateTD(CreateTR(TableEl)))), s);
+        AppendKw(CreateCode(CreatePara(CreateTD(CreateTR(TableEl)))), UTF8Decode(s));
         end;
       ct:=(Member is TPasType);
       if ct and (not wt) then
@@ -3199,7 +3174,7 @@ begin
 
       if (Member is TPasProcedureBase) then
         begin
-        AppendKw(CodeEl, TPasProcedureBase(Member).TypeName + ' ');
+        AppendKw(CodeEl, UTF8Decode(TPasProcedureBase(Member).TypeName) + ' ');
         AppendHyperlink(CodeEl, Member);
         if ah then
           AppendSym(CodeEl, '();')
@@ -3217,7 +3192,7 @@ begin
           AppendTypeDecl(TPasType(Member),TableEl,CodeEl);
           end;
         AppendSym(CodeEl, ' = ');
-        AppendText(CodeEl,TPasConst(Member).Expr.GetDeclaration(True));
+        AppendText(CodeEl,UTF8Decode(TPasConst(Member).Expr.GetDeclaration(True)));
         end
       else if (Member is TPasType) then
         begin
@@ -3246,7 +3221,7 @@ begin
         if (TPasProperty(Member).ImplementsName<>'') then
         begin
           AppendKw(CodeEl, ' implements');
-          AppendText(CodeEl, ' '+TPasProperty(Member).ImplementsName);
+          AppendText(CodeEl, ' '+UTF8Decode(TPasProperty(Member).ImplementsName));
           AppendSym(CodeEl, ';');
         end;
         SetLength(s, 0);
@@ -3257,23 +3232,23 @@ begin
         if Length(TPasProperty(Member).StoredAccessorName) > 0 then
           s := s + 's';
         if Length(s) > 0 then
-          AppendText(CodeEl, '  [' + s + ']');
+          AppendText(CodeEl, '  [' + UTF8Decode(s) + ']');
         end
       else if (Member is TPasVariable) then
         begin
         if not isRecord then
           AppendHyperlink(CodeEl, Member)
         else
-          AppendText(CodeEl, Member.Name);
+          AppendText(CodeEl, UTF8Decode(Member.Name));
         AppendSym(CodeEl, ': ');
         AppendHyperlink(CodeEl, TPasVariable(Member).VarType);
         AppendSym(CodeEl, ';');
         end
       else
-        AppendText(CreateWarning(CodeEl), '<' + Member.ClassName + '>');
+        AppendText(CreateWarning(CodeEl), '<' + UTF8Decode(Member.ClassName) + '>');
       if (Member.Hints<>[]) then
         begin
-        AppendKW(CodeEl,' '+Engine.HintsToStr(Member.Hints));
+        AppendKW(CodeEl,' '+UTF8Decode(Engine.HintsToStr(Member.Hints)));
         AppendText(CodeEl, ' ');
         AppendSym(CodeEl, ';');
         end;
@@ -3291,6 +3266,11 @@ begin
      end;
 end;
 
+procedure THTMLWriter.AppendTitle(const AText: String; Hints: TPasMemberHints);
+begin
+  AppendTitle(UTF8Decode(aText),Hints);
+end;
+
 procedure THTMLWriter.CreateClassPageBody(AClass: TPasClassType;
   ASubpageIndex: Integer);
 type
@@ -3306,18 +3286,16 @@ var
     if FUseMenuBrackets then
       AppendText(ParaEl, '[');
     LinkEl := CreateEl(ParaEl, 'a');
-    LinkEl['href'] :=
-      FixHtmlPath(ResolveLinkWithinPackage(AClass, AListSubpageIndex));
+    LinkEl['href'] :=UTF8Decode(FixHtmlPath(ResolveLinkWithinPackage(AClass, AListSubpageIndex)));
     LinkEl['onClick'] := 'window.open(''' + LinkEl['href'] + ''', ''list'', ' +
      '''dependent=yes,resizable=yes,scrollbars=yes,height=400,width=300''); return false;';
     AppendText(LinkEl, AText);
     AppendText(ParaEl, ' (');
     LinkEl := CreateEl(ParaEl, 'a');
-    LinkEl['href'] :=
-      FixHtmlPath(ResolveLinkWithinPackage(AClass, AListSubpageIndex + 1));
+    LinkEl['href'] :=UTF8Decode(FixHtmlPath(ResolveLinkWithinPackage(AClass, AListSubpageIndex + 1)));
     LinkEl['onClick'] := 'window.open(''' + LinkEl['href'] + ''', ''list'', ' +
      '''dependent=yes,resizable=yes,scrollbars=yes,height=400,width=300''); return false;';
-    AppendText(LinkEl, SDocByName);
+    AppendText(LinkEl, UTF8Decode(SDocByName));
     AppendText(ParaEl, ')');
     if FUseMenuBrackets then
       AppendText(ParaEl, '] ')
@@ -3336,7 +3314,7 @@ var
         AppendSym(CodeEl, '<')
       else
         AppendSym(CodeEl, ',');
-      AppendText(CodeEl,TPasGenericTemplateType(AList[i]).Name);
+      AppendText(CodeEl,UTF8Decode(TPasGenericTemplateType(AList[i]).Name));
       end;
     AppendSym(CodeEl, '>');
   end;
@@ -3352,15 +3330,15 @@ var
     ThisNode  : TPasUnresolvedTypeRef;
   begin
     AppendMenuBar(-1);
-    AppendTitle(AClass.Name,AClass.Hints);
+    AppendTitle(UTF8Decode(AClass.Name),AClass.Hints);
 
     ParaEl := CreatePara(BodyElement);
-    AppendMemberListLink(PropertiesByInheritanceSubindex, SDocProperties);
-    AppendMemberListLink(MethodsByInheritanceSubindex, SDocMethods);
-    AppendMemberListLink(EventsByInheritanceSubindex, SDocEvents);
+    AppendMemberListLink(PropertiesByInheritanceSubindex, UTF8Decode(SDocProperties));
+    AppendMemberListLink(MethodsByInheritanceSubindex, UTF8Decode(SDocMethods));
+    AppendMemberListLink(EventsByInheritanceSubindex, UTF8Decode(SDocEvents));
 
     AppendShortDescr(CreatePara(BodyElement), AClass);
-    AppendText(CreateH2(BodyElement), SDocDeclaration);
+    AppendText(CreateH2(BodyElement), UTF8Decode(SDocDeclaration));
     AppendSourceRef(AClass);
 
     TableEl := CreateTable(BodyElement);
@@ -3371,12 +3349,12 @@ var
     AppendKw(CodeEl, 'type');
     if AClass.GenericTemplateTypes.Count>0 then
       AppendKw(CodeEl, ' generic ');
-    AppendText(CodeEl, ' ' + AClass.Name + ' ');
+    AppendText(CodeEl, ' ' + UTF8Decode(AClass.Name) + ' ');
     if AClass.GenericTemplateTypes.Count>0 then
       AppendGenericTypes(CodeEl,AClass.GenericTemplateTypes,false);
     AppendSym(CodeEl, '=');
     AppendText(CodeEl, ' ');
-    AppendKw(CodeEl, ObjKindNames[AClass.ObjKind]);
+    AppendKw(CodeEl, UTF8Decode(ObjKindNames[AClass.ObjKind]));
 
     if Assigned(AClass.AncestorType) then
     begin
@@ -3396,7 +3374,7 @@ var
 
 
 
-    AppendText(CreateH2(BodyElement), SDocInheritance);
+    AppendText(CreateH2(BodyElement), UTF8Decode(SDocInheritance));
     TableEl := CreateTable(BodyElement);
     HaveSeenTObject := AClass.ObjKind <> okClass;
     // we try to track classes. But imported classes
@@ -3445,7 +3423,7 @@ var
             thisnode:=TPasUnresolvedTypeRef(ThisClass.ancestortype);
           TDEl := CreateTD(CreateTR(TableEl));
           TDEl['align'] := 'center';
-          AppendText(CreateCode(CreatePara(TDEl)), ThisClass.AncestorType.Name);
+          AppendText(CreateCode(CreatePara(TDEl)), UTF8Decode(ThisClass.AncestorType.Name));
           if CompareText(ThisClass.AncestorType.Name, 'TObject') = 0 then
             HaveSeenTObject := True
           else
@@ -3628,7 +3606,7 @@ var
   begin
     AppendHyperlink(CodeEl, Element.Parent);
     AppendSym(CodeEl, '.');
-    AppendText(CodeEl, Element.Name);
+    AppendText(CodeEl, UTF8Decode(Element.Name));
     if Assigned(Element.VarType) then
     begin
       AppendSym(CodeEl, ' : ');
@@ -3641,7 +3619,7 @@ var
     AppendKw(CodeEl, 'type ');
     AppendHyperlink(CodeEl, Element.Parent);
     AppendSym(CodeEl, '.');
-    AppendText(CodeEl, Element.Name);
+    AppendText(CodeEl, UTF8Decode(Element.Name));
     AppendSym(CodeEl, ' = ');
     AppendTypeDecl(Element,TableEl,CodeEl)
   end;
@@ -3651,7 +3629,7 @@ var
     AppendKw(CodeEl, 'const ');
     AppendHyperlink(CodeEl, Element.Parent);
     AppendSym(CodeEl, '.');
-    AppendText(CodeEl, Element.Name);
+    AppendText(CodeEl, UTF8Decode(Element.Name));
     if Assigned(Element.VarType) then
       begin
       AppendSym(CodeEl, ': ');
@@ -3671,7 +3649,7 @@ var
     AppendKw(CodeEl, 'property ');
     AppendHyperlink(CodeEl, Element.Parent);
     AppendSym(CodeEl, '.');
-    AppendText(CodeEl, Element.Name);
+    AppendText(CodeEl, UTF8Decode(Element.Name));
     if Assigned(Element.Args) and (Element.Args.Count>0) then
       begin
       AppendSym(CodeEl,'[');
@@ -3680,10 +3658,10 @@ var
         If I>0 then
           AppendSym(CodeEl,',');
         A:=TPasArgument(Element.Args[i]);
-        AppendText(CodeEl, A.Name);
+        AppendText(CodeEl, UTF8Decode(A.Name));
         AppendSym(CodeEl,': ');
         if Assigned(A.ArgType) then
-          AppendText(CodeEl,A.ArgType.Name)
+          AppendText(CodeEl,UTF8Decode(A.ArgType.Name))
         else
           AppendText(CodeEl,'<Unknown>');
         end;
@@ -3710,7 +3688,7 @@ var
       CreateEl(CodeEl, 'br');
       AppendNbsp(CodeEl, 2);
       AppendKw(CodeEl, 'read ');
-      AppendText(CodeEl, TPasProperty(Element).ReadAccessorName);
+      AppendText(CodeEl, UTF8Decode(TPasProperty(Element).ReadAccessorName));
       NeedBreak := True;
     end;
     if Length(TPasProperty(Element).WriteAccessorName) <> 0 then
@@ -3718,7 +3696,7 @@ var
       CreateEl(CodeEl, 'br');
       AppendNbsp(CodeEl, 2);
       AppendKw(CodeEl, 'write ');
-      AppendText(CodeEl, TPasProperty(Element).WriteAccessorName);
+      AppendText(CodeEl, UTF8Decode(TPasProperty(Element).WriteAccessorName));
       NeedBreak := True;
     end;
     if Length(TPasProperty(Element).StoredAccessorName) <> 0 then
@@ -3726,7 +3704,7 @@ var
       CreateEl(CodeEl, 'br');
       AppendNbsp(CodeEl, 2);
       AppendKw(CodeEl, 'stored ');
-      AppendText(CodeEl, TPasProperty(Element).StoredAccessorName);
+      AppendText(CodeEl, UTF8Decode(TPasProperty(Element).StoredAccessorName));
       NeedBreak := True;
     end;
     if Length(TPasProperty(Element).DefaultValue) <> 0 then
@@ -3757,10 +3735,9 @@ var
 
 var
   s: String;
-  DocNode: TDocNode;
 begin
   AppendMenuBar(-1);
-  AppendTitle(AElement.FullName,AElement.Hints);
+  AppendTitle(UTF8Decode(AElement.FullName),AElement.Hints);
   AppendShortDescr(CreatePara(BodyElement), AElement);
   AppendText(CreateH2(BodyElement), SDocDeclaration);
   AppendSourceRef(AElement);
@@ -3796,7 +3773,6 @@ end;
 procedure THTMLWriter.CreateVarPageBody(AVar: TPasVariable);
 var
   TableEl, TREl, TDEl, CodeEl, El: TDOMElement;
-  DocNode: TDocNode;
 begin
   AppendMenuBar(-1);
   AppendTitle(AVar.FullName,AVar.Hints);
@@ -3830,7 +3806,7 @@ var
   TableEl, TREl, TDEl, CodeEl: TDOMElement;
 begin
   AppendMenuBar(-1);
-  AppendTitle(AProc.Name,AProc.Hints);
+  AppendTitle(UTF8Decode(AProc.Name),AProc.Hints);
   AppendShortDescr(CreatePara(BodyElement), AProc);
   AppendText(CreateH2(BodyElement), SDocDeclaration);
   AppendSourceRef(AProc);
@@ -3938,19 +3914,12 @@ begin
 end;
 
 
-procedure THTMWriter.CreateAllocator;
-begin
-  FAllocator:=TShortNameFileAllocator.Create('.htm');
-end;
-
 initialization
   // Do not localize.
   RegisterWriter(THTMLWriter,'html','HTML output using fpdoc.css stylesheet.');
-  RegisterWriter(THTMWriter,'htm','HTM (8.3 filenames) output using fpdoc.css stylesheet.');
   RegisterWriter(TCHMHTMLWriter,'chm','Compressed HTML file output using fpdoc.css stylesheet.');
 
 finalization
   UnRegisterWriter('html');
-  UnRegisterWriter('htm');
   UnRegisterWriter('chm');
 end.
diff --git a/utils/fpdoc/dw_htmlchm.inc b/utils/fpdoc/dw_htmlchm.inc
index 98ad044a7f..c56ba72ec3 100644
--- a/utils/fpdoc/dw_htmlchm.inc
+++ b/utils/fpdoc/dw_htmlchm.inc
@@ -42,7 +42,7 @@ type
 function TCHMHTMLWriter.ResolveLinkIDAbs(const Name: String; Level : Integer = 0): DOMString;
 
 begin
-  Result:=FixHTMLpath(Engine.ResolveLink(Module,Name, True));
+  Result:=UTF8Decode(FixHTMLpath(Engine.ResolveLink(Module,Name, True)));
   // for global index: don't make it relative to the current document.
 end;
 
@@ -81,9 +81,8 @@ end;
 
 function TCHMHTMLWriter.RetrieveOtherFiles(const DataName: String; out
   PathInChm: String; out FileName: String; var Stream: TStream): Boolean;
-var
-  Dir: String;
 begin
+  Result:=True;
   if Stream <> nil then
     Stream.Free;
   Stream := TMemoryStream.Create;
@@ -150,11 +149,9 @@ procedure TCHMHTMLWriter.GenerateTOC;
 var
   TOC: TChmSiteMap;
   Element: TPasElement;
-  k: Integer;
   j: Integer;
   i: Integer;
   AModule: TPasModule;
-  Member: TPasElement;
   Stream: TMemoryStream;
   TmpItem:  TChmSiteMapItem;
   ObjByUnitItem,
@@ -292,7 +289,8 @@ var
   ParentElement: TPasElement;
   MemberItem: TChmSiteMapItem;
   Stream: TMemoryStream;
-  s: string;
+  s: String;
+
 begin
   DoLog('Generating Index...');
 
@@ -320,9 +318,9 @@ begin
         begin
           TmpElement := TPasElement(TPasClassType(ParentElement).Members.Items[k]);
           if TmpElement is TPasEnumValue then
-             s := ResolveLinkIDAbs(tmpElement.Parent.PathName)
+             s := UTF8Encode(ResolveLinkIDAbs(tmpElement.Parent.PathName))
            else
-             s := ResolveLinkIDAbs(tmpElement.PathName);
+             s := UTF8Encode(ResolveLinkIDAbs(tmpElement.PathName));
            if Engine.HidePrivate and(TmpElement.Visibility = visPrivate) then
             continue;
           if Engine.HideProtected and(TmpElement.Visibility = visProtected) then
diff --git a/utils/fpdoc/dw_ipflin.pas b/utils/fpdoc/dw_ipflin.pas
index 7df128caeb..8bf9e117cc 100644
--- a/utils/fpdoc/dw_ipflin.pas
+++ b/utils/fpdoc/dw_ipflin.pas
@@ -14,7 +14,7 @@
 unit dw_ipflin;
 
 {$mode objfpc}{$H+}
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses
@@ -38,7 +38,6 @@ type
     InHeading: Boolean;
     FInHeadingText: string;
     OrderedList: boolean;
-    TableRowStartFlag: Boolean;
     TableCaptionWritten: Boolean;
     InTableCell: Boolean;
     InTypesDeclaration: Boolean;
@@ -205,12 +204,12 @@ begin
   // IPF has an imposed line length limit.
   if (Length(AText) > cMax) then // then we need to wrap the text.
   begin
-    lText := WrapText(AText, LineEnding, [' ', '-', #9], cMax);
+    lText := WrapText(UTF8Encode(AText), LineEnding, [' ', '-', #9], cMax);
     sl := TStringlist.Create;
     try
       sl.Text := lText;
       for i := 0 to sl.Count-1 do
-        inherited DescrWriteText(sl.Strings[i] + LineEnding);
+        inherited DescrWriteText(UTF8Decode(sl.Strings[i] + LineEnding));
     finally
       sl.Free;
     end;
@@ -246,7 +245,7 @@ end;
 procedure TIPFNewWriter.DescrBeginLink(const AId: DOMString);
 begin
   { Start link to label ID - links are never nested.}
-  FLink := Engine.ResolveLink(Module, AId);
+  FLink := Engine.ResolveLink(Module, UTF8Encode(AId));
   FLink := StringReplace(FLink, ':', '_', [rfReplaceAll]);
   FLink := StringReplace(FLink, '.', '_', [rfReplaceAll]);
   WriteF(':link reftype=hd refid=%s.', [flink]);
@@ -287,7 +286,7 @@ end;
 procedure TIPFNewWriter.DescrWriteCodeLine(const ALine: String);
 begin
   { Write line of code }
-  DescrWriteText(ALine + LineEnding);
+  DescrWriteText(UTF8Decode(ALine + LineEnding));
 //  writeln(EscapeText(ALine));
 end;
 
@@ -505,7 +504,6 @@ end;
 
 procedure TIPFNewWriter.WriteClassInheritanceOverview(ClassDecl: TPasClassType);
 var
-  DocNode: TDocNode;
   ancestor: TPasClassType;
   ancestor2: TPasType;
   List: TStringList;
@@ -516,7 +514,6 @@ var
   var
     s: string;
     o: TPasClassType;
-    t: string;
   begin
     if List.Objects[i] <> nil then
     begin
@@ -525,7 +522,7 @@ var
       begin
         s := ChangeFileExt(ExtractFileName(o.SourceFilename), '');
         s := '#' + PackageName + '.' + s + '.' + o.Name;
-        DescrBeginLink(s);
+        DescrBeginLink(UTF8Decode(s));
         Write(o.Name);
         DescrEndLink;
         writeln('');
@@ -623,7 +620,7 @@ end;
 
 procedure TIPFNewWriter.DescrBeginURL(const AURL: DOMString);
 begin
-  Write(':link reftype=launch object=''netscape'' data=''' + AURL + '''.');
+  Write(':link reftype=launch object=''netscape'' data=''' + UTF8Encode(AURL) + '''.');
 end;
 
 procedure TIPFNewWriter.DescrEndURL;
@@ -648,7 +645,7 @@ function TIPFNewWriter.EscapeText(S: String): String;
 var
   i: Integer;
 begin
-  SetLength(Result, 0);
+  Result:='';
   for i := 1 to Length(S) do
     case S[i] of
       '.':              // Escape these characters
@@ -704,8 +701,7 @@ function TIPFNewWriter.StripText(S: String): String;
 var
   I: Integer;
 begin
-  //Result := S;
-  SetLength(Result, 0);
+  Result := '';
   for i := 1 to Length(S) do
     if not (S[i] in ['&','{','}','#'{,'_'},'$','%','''','~','^', '\', ' ', '<', '>']) then
       Result := Result + S[i];
diff --git a/utils/fpdoc/dw_latex.pp b/utils/fpdoc/dw_latex.pp
index 22d261da28..8632cf2621 100644
--- a/utils/fpdoc/dw_latex.pp
+++ b/utils/fpdoc/dw_latex.pp
@@ -16,7 +16,7 @@
 {$mode objfpc}
 {$H+}
 unit dw_LaTeX;
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses DOM, dGlobals, PasTree;
@@ -69,7 +69,7 @@ Type
     procedure StartListing(Frames: Boolean; const name: String); override;
     procedure EndListing; override;
     Function  EscapeText(S : String) : String; override;
-    Function  StripText(S : String) : String; override;
+    Function  StripText(S : String) : String; override;overload;
     procedure WriteCommentLine; override;
     procedure WriteComment(Comment : String);override;
     procedure StartSection(SectionName : String);override;
@@ -248,7 +248,7 @@ var
   I: Integer;
 
 begin
-  SetLength(Result, 0);
+  Result:='';
   for i := 1 to Length(S) do
     If not (S[i] in ['&','{','}','#','_','$','%','''','~','^', '\']) then
       Result := Result + S[i]
@@ -292,19 +292,23 @@ procedure TLaTeXWriter.DescrWriteImageEl(const AFileName, ACaption, ALinkName :
 Var
   FN : String;
   L : Integer;
+  S : String;
   
 begin
   Writeln('\begin{figure}[ht]%');
   Writeln('\begin{center}');
   If (ACaption<>ACaption) then
-    Writeln(Format('\caption{%s}',[EscapeText(ACaption)]));
+    begin
+    S:=EscapeText(ACaption);
+    Writeln(Format('\caption{%s}',[S]));
+    end;
   If (ALinkName<>'') then
-    WriteLabel('fig:'+ALinkName);
+    WriteLabel('fig:'+Utf8Encode(ALinkName));
   FN:=ImageDir;
   L:=Length(FN);
   If (L>0) and (FN[l]<>'/')  then
     FN:=FN+'/';
-  FN:=FN+AFileName;
+  FN:=FN+Utf8Encode(AFileName);
   Writeln('\epsfig{file='+FN+'}');
   Writeln('\end{center}');
   Writeln('\end{figure}');
@@ -333,7 +337,7 @@ end;
 
 procedure TLaTeXWriter.DescrBeginLink(const AId: DOMString);
 begin
-  FLink := Engine.ResolveLink(Module, AId);
+  FLink := Engine.ResolveLink(Module, UTF8Encode(AId));
 //  System.WriteLn('Link "', AId, '" => ', FLink);
 end;
 
@@ -575,6 +579,7 @@ begin
     Writeln('\end{verbatim}')
 end;
 
+
 procedure TLaTeXWriter.WriteCommentLine;
 const
   CommentLine =
diff --git a/utils/fpdoc/dw_linrtf.pp b/utils/fpdoc/dw_linrtf.pp
index 6d9a236f57..7efbecf504 100644
--- a/utils/fpdoc/dw_linrtf.pp
+++ b/utils/fpdoc/dw_linrtf.pp
@@ -15,7 +15,7 @@
 {$mode objfpc}
 {$H+}
 unit dw_LinRTF;
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses DOM, dGlobals, PasTree;
@@ -160,8 +160,8 @@ type
     procedure DescrBeginTableCell; override;
     procedure DescrEndTableCell; override;
     // TFPDocWriter class methods
-    Function InterPretOption(Const Cmd,Arg : String) : boolean; override;
   public
+    Function InterPretOption(Const Cmd,Arg : String) : boolean; override;
     Class Function FileNameExtension : String; override;
   end;
 
@@ -212,7 +212,7 @@ var
   I: Integer;
 
 begin
-  SetLength(Result, 0);
+  Result:='';
   for i := 1 to Length(S) do
     If not (S[i] in ['{','}','\']) then
       Result := Result + S[i];
@@ -367,7 +367,7 @@ end;
 
 procedure TRTFWriter.DescrBeginLink(const AId: DOMString);
 begin
-  FLink := Engine.ResolveLink(Module, AId);
+  FLink := Engine.ResolveLink(Module, Utf8Encode(AId));
 //  System.WriteLn('Link "', AId, '" => ', FLink);
 end;
 
diff --git a/utils/fpdoc/dw_man.pp b/utils/fpdoc/dw_man.pp
index 4d8f2e4856..c6900bdd33 100644
--- a/utils/fpdoc/dw_man.pp
+++ b/utils/fpdoc/dw_man.pp
@@ -1,7 +1,7 @@
 {$mode objfpc}
 {$H+}
 unit dw_man;
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses
@@ -389,7 +389,7 @@ end;
 procedure TManWriter.DescrWriteText(const AText: DOMString);
 
 begin
-  self.Write(EscapeText(AText));
+  self.Write(EscapeText(Utf8Encode(AText)));
 end;
 
 procedure TManWriter.DescrBeginBold;
@@ -432,7 +432,7 @@ Var
 
 begin
   NewLine;
-  S:=AText;
+  S:=UTF8Encode(AText);
   Writeln('.I '+S);
 end;
 
@@ -443,7 +443,7 @@ Var
 
 begin
   NewLine;
-  S:=AText;
+  S:=Utf8Encode(AText);
   Writeln('.B '+S);
 end;
 
@@ -454,7 +454,7 @@ Var
 
 begin
   NewLine;
-  S:=AText;
+  S:=Utf8Encode(AText);
   Writeln('.B '+S);
 end;
 
@@ -884,7 +884,7 @@ begin
     begin
     if IsLinkNode(Node) then
       begin
-      S:=TDomElement(Node)['id'];
+      S:=UTF8Encode(TDomElement(Node)['id']);
       WriteManRef(S,(Node.NextSibling<>Nil) or Comma);
       end;
     Node:=Node.NextSibling;
@@ -1545,6 +1545,8 @@ var
   i : integer;
   D,N : String;
 begin
+  N:=ProcDecl.name;
+  D:='';
   DocNode := Engine.FindDocNode(ProcDecl);
   StartManpage(ProcDecl,DocNode);
   Try
@@ -1670,6 +1672,7 @@ begin
   DocNode := Engine.FindDocNode(PropDecl);
   StartManpage(PropDecl,DocNode);
   Try
+    N:= PropDecl.Name;
     PageTitle(PropDecl.Name,ManSection,PackageName,PackageDescr);
     if Assigned(DocNode) then
     D:=GetDescrString(PropDecl,DocNode.ShortDescr);
diff --git a/utils/fpdoc/dw_txt.pp b/utils/fpdoc/dw_txt.pp
index cbd8cb8b24..234d5187db 100644
--- a/utils/fpdoc/dw_txt.pp
+++ b/utils/fpdoc/dw_txt.pp
@@ -15,7 +15,7 @@
 {$mode objfpc}
 {$H+}
 unit dw_txt;
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses DOM, dGlobals, PasTree, dwriter;
diff --git a/utils/fpdoc/dw_xml.pp b/utils/fpdoc/dw_xml.pp
index 5930918afb..2d31e2a68b 100644
--- a/utils/fpdoc/dw_xml.pp
+++ b/utils/fpdoc/dw_xml.pp
@@ -84,8 +84,8 @@ var
     if not FShowSourceInfo then
       Exit;
     SourceNode := Doc.CreateElement('source');
-    SourceNode['line'] := IntToStr(ADecl.SourceLinenumber);
-    SourceNode['file'] := ADecl.SourceFilename;
+    SourceNode['line'] := UTF8Decode(IntToStr(ADecl.SourceLinenumber));
+    SourceNode['file'] := UTF8Decode(ADecl.SourceFilename);
     AElement.AppendChild(SourceNode);
   end;
 
@@ -114,7 +114,7 @@ var
 
   procedure AddTypeNode(ToNode: TDOMElement; AType: String);
   begin
-    ToNode.AttribStrings['type'] := AType;
+    ToNode.AttribStrings['type'] := UTF8Decode(AType);
   end;
 
   function AddTypeNode(ToNode: TDOMElement; AType: TPasType): Boolean;
@@ -141,7 +141,7 @@ var
     begin
       Arg := TPasArgument(Args.Items[i]);
       ArgNode := Doc.CreateElement('argument');
-      ArgNode.AttribStrings['name'] := Arg.Name;
+      ArgNode.AttribStrings['name'] := UTF8Decode(Arg.Name);
       AddTypeNode(ArgNode, Arg.ArgType);
       ProcNode.AppendChild(ArgNode);
     end;
@@ -150,7 +150,7 @@ var
   procedure DoVisibility(PasEl: TPasElement; Element: TDOMElement);
   begin
     if PasEl.Visibility <> visDefault then
-      Element['visibility'] := VisibilityToString(PasEl.Visibility);
+      Element['visibility'] := UTF8Decode(VisibilityToString(PasEl.Visibility));
   end;
 
   function ProcessProcedure(Proc: TPasProcedure; Element: TDOMElement): TDOMElement;
@@ -159,9 +159,9 @@ var
     ReturnEl: TDOMElement;
   begin
     Result := nil;
-    ProcEl := Doc.CreateElement(Sanitize(Proc.TypeName));
+    ProcEl := Doc.CreateElement(UTF8Decode(Sanitize(Proc.TypeName)));
     Element.AppendChild(ProcEl);
-    ProcEl['name'] := Proc.Name;
+    ProcEl['name'] := UTF8Decode(Proc.Name);
 
     DoVisibility(Proc, ProcEl);
 
@@ -185,10 +185,10 @@ var
     TypeEl: TDOMElement;
   begin
     TypeEl := Doc.CreateElement('array');
-    TypeEl['name'] := AType.Name;
+    TypeEl['name'] := UTF8Decode(AType.Name);
     if not AddTypeNode(TypeEl, AType.ElType) then
       TypeEl['const'] := 'true';
-    TypeEl['range'] := AType.IndexRange;
+    TypeEl['range'] := UTF8Decode(AType.IndexRange);
     DoVisibility(AType, Element);
     AddSourceInfo(AType,Element);
     Element.AppendChild(TypeEl);
@@ -199,7 +199,7 @@ var
     TypeEl: TDOMElement;
   begin
     TypeEl := Doc.CreateElement('pointer');
-    TypeEl['name'] := AType.Name;
+    TypeEl['name'] := UTF8Decode(AType.Name);
     AddTypeNode(TypeEl, AType.DestType);
     DoVisibility(AType, Element);
     AddSourceInfo(AType,Element);
@@ -212,7 +212,7 @@ var
     TypeEl: TDOMElement;
   begin
     TypeEl := Doc.CreateElement('alias');
-    TypeEl['name'] := AType.Name;
+    TypeEl['name'] := UTF8Decode(AType.Name);
     AddTypeNode(TypeEl, AType.DestType);
     DoVisibility(AType, Element);
     AddSourceInfo(AType,Element);
@@ -225,7 +225,7 @@ var
   begin
     VarEl := Result.CreateElement('var');
     Element.AppendChild(VarEl);
-    VarEl['name'] := AVar.Name;
+    VarEl['name'] := UTF8Decode(AVar.Name);
     if not AVar.VarType.InheritsFrom(TPasArrayType) then
       AddTypeNode(VarEl, AVar.VarType)
     else
@@ -244,14 +244,14 @@ var
     PropEl := Doc.CreateElement('property');
     Element.AppendChild(PropEl);
 
-    PropEl.AttribStrings['name'] := AProp.Name;
+    PropEl.AttribStrings['name'] := UTF8Decode(AProp.Name);
     AddTypeNode(PropEL, AProp.ResolvedType);
 
     if AProp.IndexValue <> '' then
-      PropEl['index'] := AProp.IndexValue;
+      PropEl['index'] := UTF8Decode(AProp.IndexValue);
 
     if AProp.DefaultValue <> '' then
-      PropEl['default'] := AProp.DefaultValue;
+      PropEl['default'] := UTF8Decode(AProp.DefaultValue);
 
 
     if AProp.WriteAccessorName <> '' then
@@ -283,8 +283,8 @@ var
     ConstEl: TDOMElement;
   begin
     ConstEl := Doc.CreateElement('const');
-    ConstEl['name'] := AConst.name;
-    ConstEl['value'] := AConst.Value;
+    ConstEl['name'] := UTF8Decode(AConst.name);
+    ConstEl['value'] := UTF8Decode(AConst.Value);
     Element.AppendChild(ConstEl);
     AddSourceInfo(AConst,ConstEl);
   end;
@@ -296,13 +296,13 @@ var
     i: Integer;
   begin
     TypeEl := Doc.CreateElement('enum');
-    TypeEl['name'] := AType.name;
+    TypeEl['name'] := UTF8Decode(AType.name);
     AddSourceInfo(AType,TypeEl);
     //ConstEl['value'] := AConst.Value;
     for i := 0 to AType.Values.Count-1 do
     begin
       ValEl := Doc.CreateElement('enumvalue');
-      ValEl['name'] := TPasEnumValue(AType.Values.Items[i]).Name;
+      ValEl['name'] := UTF8Decode(TPasEnumValue(AType.Values.Items[i]).Name);
       AddSourceInfo(TPasEnumValue(AType.Values.Items[i]),ValEl);
       TypeEl.AppendChild(ValEl);
 
@@ -315,7 +315,7 @@ var
     SetEl: TDOMElement;
   begin
     SetEl := Doc.CreateElement('set');
-    SetEl['name'] := AType.name;
+    SetEl['name'] := UTF8Decode(AType.name);
     AddTypeNode(SetEl, AType.EnumType);
     AddSourceInfo(AType,SetEl);
     Element.AppendChild(SetEl);
@@ -325,8 +325,8 @@ var
   var
     TypeEl: TDOMElement;
   begin
-    TypeEl := Doc.CreateElement(AType.TypeName);
-    TypeEl['name'] := AType.name;
+    TypeEl := Doc.CreateElement(UTF8Decode(AType.TypeName));
+    TypeEl['name'] := UTF8Decode(AType.name);
     TypeEl['istype'] := 'true';
     if AType.IsOfObject then
       TypeEl['object'] := 'true';
@@ -342,7 +342,7 @@ var
     i: Integer;
   begin
     TypeEl := Doc.CreateElement('record');
-    TypeEl['name'] := AType.name;
+    TypeEl['name'] := UTF8Decode(AType.name);
 
     Element.AppendChild(TypeEl);
     AddSourceInfo(AType,TypeEl);
@@ -369,7 +369,7 @@ var
     for i := 0 to AGenericTypes.Count-1 do
     begin
       Node := Doc.CreateElement('t');
-      Node['name'] := TPasGenericTemplateType(AGenericTypes.Items[i]).Name;
+      Node['name'] := UTF8Decode(TPasGenericTemplateType(AGenericTypes.Items[i]).Name);
       ANode.AppendChild(Node);
       AddSourceInfo(TPasGenericTemplateType(AGenericTypes.Items[i]),Node);
     end;
@@ -380,9 +380,9 @@ var
     TypeEl: TDOMElement;
   begin
     TypeEl := Doc.CreateElement('range');
-    TypeEl['name'] := AType.Name;
-    TypeEl['start'] := AType.RangeStart;
-    TypeEl['end'] := AType.RangeEnd;
+    TypeEl['name'] := UTF8Decode(AType.Name);
+    TypeEl['start'] := UTF8Decode(AType.RangeStart);
+    TypeEl['end'] := UTF8Decode(AType.RangeEnd);
     AddSourceInfo(AType,TypeEl);
 
     Element.AppendChild(TypeEl);
@@ -452,9 +452,9 @@ var
     if Assigned(ClassEl) then
     begin
       Element.AppendChild(ClassEl);
-      ClassEl['name'] := AClass.Name;
+      ClassEl['name'] := UTF8Decode(AClass.Name);
       if Assigned(AClass.AncestorType) then
-        ClassEl['parentclass'] := AClass.AncestorType.Name;
+        ClassEl['parentclass'] := UTF8Decode(AClass.AncestorType.Name);
 
       AddSourceInfo(AClass,ClassEl);
 
@@ -463,7 +463,7 @@ var
         begin
           InterfaceEl := Doc.CreateElement('interface');
           ClassEl.AppendChild(InterfaceEl);
-          InterfaceEl['name'] := TPasElement(AClass.Interfaces.Items[i]).Name;
+          InterfaceEl['name'] := UTF8Decode(TPasElement(AClass.Interfaces.Items[i]).Name);
         end;
 
       if Assigned(AClass.Members) then
@@ -521,7 +521,7 @@ var
       for i := 0 to ASection.UsesList.Count - 1 do
       begin
         UnitElement := Result.CreateElement('unit-ref');
-        UnitElement['name'] := TPasType(ASection.UsesList[i]).Name;
+        UnitElement['name'] := UTF8Decode(TPasType(ASection.UsesList[i]).Name);
         UsesElement.AppendChild(UnitElement);
       end;
     end;
@@ -575,10 +575,10 @@ var
 
 begin
   Result := TXMLDocument.Create;
-  Result.AppendChild(Result.CreateComment(SDocGeneratedByComment));
+  Result.AppendChild(Result.CreateComment(UTF8Decode(SDocGeneratedByComment)));
   Result.AppendChild(Result.CreateElement('fp-refdoc'));
   ModuleElement := Result.CreateElement('unit');
-  ModuleElement['name'] := AModule.Name;
+  ModuleElement['name'] := UTF8Decode(AModule.Name);
   Result.DocumentElement.AppendChild(ModuleElement);
   ProcessSection(AModule.InterfaceSection, 'interface');
 end;
diff --git a/utils/fpdoc/dwlinear.pp b/utils/fpdoc/dwlinear.pp
index ef485e64ad..5b36cec805 100644
--- a/utils/fpdoc/dwlinear.pp
+++ b/utils/fpdoc/dwlinear.pp
@@ -1,7 +1,7 @@
 {$mode objfpc}
 {$H+}
 unit dwlinear;
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses
@@ -47,7 +47,8 @@ Type
     // Procedures which MAY be overridden in descendents
     procedure WriteBeginDocument; virtual;
     procedure WriteEndDocument; virtual;
-    Function  EscapeText(S : String) : String; virtual;
+    Function  EscapeText(S : UnicodeString) : String; overload;
+    Function  EscapeText(S : String) : String; virtual; overload;
     Function  StripText(S : String) : String; virtual;
     Procedure StartProcedure; Virtual;
     Procedure EndProcedure; Virtual;
@@ -523,7 +524,7 @@ procedure TLinearWriter.WriteClassInterfacesOverview(ClassDecl: TPasClassType);
 var
   lInterface: TPasElement;
   i: Integer;
-  L,N,S,A: String;
+  L,N,S: String;
   DocNode: TDocNode;
   List : TStringList;
   lNode: TDocNode;
@@ -688,7 +689,7 @@ begin
     begin
       ResStrDecl := TPasResString(ASection.ResStrings[i]);
       StartListing(false, '');
-      DescrWriteText(ResStrDecl.GetDeclaration(True)); // instead of WriteLn() so we can do further processing like manual line wrapping in descendants
+      DescrWriteText(UTF8Decode(ResStrDecl.GetDeclaration(True))); // instead of WriteLn() so we can do further processing like manual line wrapping in descendants
       EndListing;
       WriteLabel(ResStrDecl);
       WriteIndex(ResStrDecl);
@@ -869,10 +870,8 @@ end;
 
 procedure TLinearWriter.WriteTypes(ASection: TPasSection);
 var
-  i,j: Integer;
+  i: Integer;
   TypeDecl: TPasType;
-  Recdecl: TPasRecordType;
-  Member : TPasElement;
   DocNode : TDocNode;
 begin
   if ASection.Types.Count > 0 then
@@ -1109,7 +1108,7 @@ begin
       Writeln(VisibilityNames[Visibility])
       end;
     StartAccess;
-    Setlength(S,0);
+    S:='';
     If Length(ReadAccessorName) > 0 then
       S:='Read';
     if Length(WriteAccessorName) > 0 then
@@ -1150,7 +1149,7 @@ procedure TLinearWriter.WriteSeeAlso(ADocNode: TDocNode);
 
 var
   Node: TDOMNode;
-  s: String;
+  s: DOMString;
   First : Boolean;
 
 begin
@@ -1484,6 +1483,11 @@ begin
   // do nothing
 end;
 
+function TLinearWriter.EscapeText(S: UnicodeString): String;
+begin
+  Result:=EscapeText(UTF8Encode(S));
+end;
+
 function TLinearWriter.InterpretOption(const Cmd, Arg: String): Boolean;
 begin
   Result := True;
diff --git a/utils/fpdoc/dwriter.pp b/utils/fpdoc/dwriter.pp
index 02de0304d6..ca7faa2a14 100644
--- a/utils/fpdoc/dwriter.pp
+++ b/utils/fpdoc/dwriter.pp
@@ -22,7 +22,7 @@ unit dWriter;
 
 {$MODE objfpc}
 {$H+}
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses Classes, DOM, dGlobals, PasTree, SysUtils;
@@ -571,7 +571,7 @@ function TFPDocWriter.ConvertBaseShort(AContext: TPasElement;
     begin
       s := Node.NodeValue;
       i := 1;
-      SetLength(Result, 0);
+      Result:='';
       while i <= Length(s) do
         if s[i] = #13 then
         begin
@@ -604,7 +604,7 @@ function TFPDocWriter.ConvertBaseShort(AContext: TPasElement;
 
   function ConvertTextContent: DOMString;
   begin
-    SetLength(Result, 0);
+    Result:='';
     Node := Node.FirstChild;
     while Assigned(Node) do
     begin
@@ -615,7 +615,6 @@ function TFPDocWriter.ConvertBaseShort(AContext: TPasElement;
 
 var
   El, DescrEl: TDOMElement;
-  FPEl: TPasElement;
   hlp : TPasElement;
 begin
   Result := True;
@@ -650,7 +649,7 @@ begin
         hlp:=hlp.parent;
       if not (hlp is TPasModule) then
         hlp:=nil;
-      DescrEl := Engine.FindShortDescr(TPasModule(hlp), El['id']);
+      DescrEl := Engine.FindShortDescr(TPasModule(hlp), UTF8Encode(El['id']));
       if Assigned(DescrEl) then
         ConvertShort(AContext, DescrEl)
       else
@@ -859,7 +858,7 @@ function TFPDocWriter.ConvertNonSectionBlock(AContext: TPasElement;
     end;
 
   var
-    s: String;
+    s: DOMString;
     HasBorder, CaptionPossible, HeadRowPossible: Boolean;
     ColCount, ThisRowColCount: Integer;
     Subnode: TDOMNode;
@@ -1031,12 +1030,12 @@ function TFPDocWriter.ConvertSimpleBlock(AContext: TPasElement;
     i, j: Integer;
   begin
     Node := Node.FirstChild;
-    SetLength(s, 0);
+    S:='';
     while Assigned(Node) do
     begin
       if Node.NodeType = TEXT_NODE then
       begin
-        s := s + Node.NodeValue;
+        s := s + UTF8Encode(Node.NodeValue);
         j := 1;
         for i := 1 to Length(s) do
           // In XML, linefeeds are normalized to #10 by the parser!
@@ -1055,7 +1054,7 @@ function TFPDocWriter.ConvertSimpleBlock(AContext: TPasElement;
   end;
 
 var
-  s: String;
+  s: DOMString;
   HasBorder: Boolean;
 begin
   if Node.NodeType <> ELEMENT_NODE then
@@ -1081,7 +1080,7 @@ begin
         Warning(AContext, SErrInvalidBorderValue, ['<code>']);
     end;
 
-    DescrBeginCode(HasBorder, TDOMElement(Node)['highlighter']);
+    DescrBeginCode(HasBorder, UTF8Encode(TDOMElement(Node)['highlighter']));
     ProcessCodeBody(Node);
     DescrEndCode;
     Result := True;
@@ -1128,7 +1127,7 @@ begin
   FN:=El['file'];
   Cap:=El['caption'];
   LinkName:=El['name'];
-  FN:=ChangeFileExt(FN,ImageExtension);
+  FN:=UTF8decode(ChangeFileExt(UTF8Encode(FN),ImageExtension));
   DescrWriteImageEl(FN,Cap,LinkName);
 end;
 
@@ -1136,7 +1135,7 @@ procedure TFPDocWriter.DescrEmitNotesHeader(AContext: TPasElement);
 begin
   DescrWriteLinebreak;
   DescrBeginBold;
-  DescrWriteText(SDocNotes);
+  DescrWriteText(UTF8Decode(SDocNotes));
   DescrEndBold;
   DescrWriteLinebreak;
 end;
diff --git a/utils/fpdoc/examples/simple/html.sh b/utils/fpdoc/examples/simple/html.sh
index de9e772e9c..0c522da4d0 100644
--- a/utils/fpdoc/examples/simple/html.sh
+++ b/utils/fpdoc/examples/simple/html.sh
@@ -1,2 +1,2 @@
 #!/bin/sh
-fpdoc --package=fpdocsample --output=doc --format=html --input='-S2 testunit.pp' --descr=testunit.xml
+../../fpdoc --package=fpdocsample --output=doc --format=html --input='-S2 testunit.pp' --descr=testunit.xml
diff --git a/utils/fpdoc/fpclasschart.lpi b/utils/fpdoc/fpclasschart.lpi
index bf0b95eed5..c9da7c8161 100644
--- a/utils/fpdoc/fpclasschart.lpi
+++ b/utils/fpdoc/fpclasschart.lpi
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
     <Version Value="9"/>
@@ -28,6 +28,7 @@
     <RunParams>
       <local>
         <FormatVersion Value="1"/>
+        <CommandLineParams Value="--output=rtlclasses.xml --kind=class --format=xml --input='-Sd -dfpdocsystem -dHASGETHEAPSTATUS -dSUPPORT_DOUBLE /home/michael/rtl/linux/system.pp -Fi/home/michael/rtl/linux -Fi/home/michael//rtl/unix -Fi/home/michael/rtl/inc -Fi/home/michael/rtl/i386 -dCPU32 -dHASVARIANT -dFPC_HAS_TYPE_EXTENDED -dHASWIDECHAR&quot; --input=&quot;-Sd -dHASINTF /home/michael/rtl/objpas/objpas.pp&quot; --input=&quot;-Sd /home/michael/rtl/unix/sysutils.pp -Fi/home/michael/rtl/objpas/sysutils -Fi/home/michael//rtl/inc  /home/michael/rtl/unix/classes.pp -Fi/home/michael/rtl/objpas/classes  -dfpdocsystem&quot;"/>
         <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
       </local>
     </RunParams>
@@ -35,7 +36,6 @@
       <Unit0>
         <Filename Value="fpclasschart.pp"/>
         <IsPartOfProject Value="True"/>
-        <UnitName Value="fpclasschart"/>
       </Unit0>
       <Unit1>
         <Filename Value="dglobals.pp"/>
@@ -45,7 +45,6 @@
       <Unit2>
         <Filename Value="fpdocclasstree.pp"/>
         <IsPartOfProject Value="True"/>
-        <UnitName Value="fpdocclasstree"/>
       </Unit2>
     </Units>
   </ProjectOptions>
@@ -56,8 +55,5 @@
         <UseAnsiStrings Value="False"/>
       </SyntaxOptions>
     </Parsing>
-    <Other>
-      <CompilerPath Value="$(CompPath)"/>
-    </Other>
   </CompilerOptions>
 </CONFIG>
diff --git a/utils/fpdoc/fpdoc.pp b/utils/fpdoc/fpdoc.pp
index 999e31efb5..0ce9f25fb5 100644
--- a/utils/fpdoc/fpdoc.pp
+++ b/utils/fpdoc/fpdoc.pp
@@ -288,7 +288,7 @@ procedure TFPDocApplication.ParseOption(Const S : String);
 
 var
   i: Integer;
-  ProjectFileName,Cmd, Arg: String;
+  Cmd, Arg: String;
 
 begin
   if (s = '-h') or (s = '--help') then
diff --git a/utils/fpdoc/fpdocclasstree.pp b/utils/fpdoc/fpdocclasstree.pp
index 9f5f703842..9b6ff5c218 100644
--- a/utils/fpdoc/fpdocclasstree.pp
+++ b/utils/fpdoc/fpdocclasstree.pp
@@ -72,16 +72,17 @@ end;
 Function TClassTreeBuilder.NodeMatch(N : TDomNode; AElement : TPasElement; NoPath : Boolean) : Boolean;
 
 Var
-  PN,S : String;
+  PN,S,EN : String;
 
 begin
+  EN:=AELement.Name;
   Result:=(N.NodeType=ELEMENT_NODE);
   if Result then
     begin
-    S:=N.NodeName;
+    S:=UTF8Encode(N.NodeName);
     if NoPath then
       Begin
-      Result:=(CompareText(S,AElement.Name)=0);
+      Result:=CompareText(S,EN)=0;
       end
     else
       begin
@@ -89,7 +90,7 @@ begin
         PN:=Aelement.GetModule.PackageName
       else
         PN:=FPackage.Name;
-      S:=PN+'.'+TDomElement(N)['unit']+'.'+S;
+      S:=PN+'.'+UTF8Encode(TDomElement(N)['unit'])+'.'+S;
       Result:=(CompareText(S,AElement.PathName)=0);
       end;
    end;
@@ -167,12 +168,12 @@ begin
   else if AElement.Name<>'' then
     begin // N=NIL, PE might be nil.
     Inc(ACount);
-    Result:=FClassTree.CreateElement(AElement.Name);
+    Result:=FClassTree.CreateElement(UTF8Decode(AElement.Name));
     If Not (AElement is TPasUnresolvedTypeRef) then
       begin
       M:=AElement.GetModule;
       if Assigned(M) then
-        Result['unit']:=M.Name;
+        Result['unit']:=UTF8Decode(M.Name);
       end;
     if PE=Nil then
       begin
diff --git a/utils/fpdoc/fpdocxmlopts.pas b/utils/fpdoc/fpdocxmlopts.pas
index 4a88ebb5d1..893b13733c 100644
--- a/utils/fpdoc/fpdocxmlopts.pas
+++ b/utils/fpdoc/fpdocxmlopts.pas
@@ -1,7 +1,7 @@
 unit fpdocxmlopts;
 
 {$mode objfpc}{$H+}
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses
@@ -80,21 +80,22 @@ end;
 
 procedure TXMLFPDocOptions.LoadPackage(APackage: TFPDocPackage; E: TDOMElement);
 
-  Function LoadInput(I : TDOMElement) : String;
+  Function LoadInput(I : TDOMElement) : UnicodeString;
 
   Var
-    S : String;
+    S : UnicodeString;
 
   begin
     Result:=I['file'];
     If (Result='') then
       Error(SErrNoInputFile);
     S:=I['options'];
+    Writeln('Options : ',S);
     if (S<>'') then
       Result:=S+' '+Result;
   end;
 
-  Function LoadDescription(I : TDOMElement) : String;
+  Function LoadDescription(I : TDOMElement) : UnicodeString;
 
   begin
     Result:=I['file'];
@@ -102,10 +103,11 @@ procedure TXMLFPDocOptions.LoadPackage(APackage: TFPDocPackage; E: TDOMElement);
       Error(SErrNoDescrFile);
   end;
 
-  Function LoadImport(I : TDOMElement) : String;
+  Function LoadImport(I : TDOMElement) : UnicodeString;
 
   Var
-    S : String;
+    S : UnicodeString;
+
   begin
     Result:=I['file'];
     If (Result='') then
@@ -121,9 +123,9 @@ Var
   O : TDomElement;
 
 begin
-  APackage.Name:=E['name'];
-  APackage.output:=E['output'];
-  APackage.ContentFile:=E['content'];
+  APackage.Name:=UTF8Encode(E['name']);
+  APackage.output:=UTF8Encode(E['output']);
+  APackage.ContentFile:=UTF8Encode(E['content']);
   N:=E.FirstChild;
   While (N<>Nil) do
     begin
@@ -136,7 +138,7 @@ begin
         While (S<>Nil) do
           begin
           If (S.NodeType=Element_Node) and (S.NodeName='unit') then
-            APackage.Inputs.add(LoadInput(S as TDomElement));
+            APackage.Inputs.add(UTF8Encode(LoadInput(S as TDomElement)));
           S:=S.NextSibling;
           end;
         end
@@ -146,7 +148,7 @@ begin
         While (S<>Nil) do
           begin
           If (S.NodeType=Element_Node) and (S.NodeName='description') then
-            APackage.Descriptions.add(LoadDescription(S as TDomElement));
+            APackage.Descriptions.add(UTF8Encode(LoadDescription(S as TDomElement)));
           S:=S.NextSibling;
           end;
         end
@@ -156,7 +158,7 @@ begin
         While (S<>Nil) do
           begin
           If (S.NodeType=Element_Node) and (S.NodeName='import') then
-            APackage.Imports.add(LoadImport(S as TDomElement));
+            APackage.Imports.add(UTF8Encode(LoadImport(S as TDomElement)));
           S:=S.NextSibling;
           end;
         end
@@ -202,8 +204,8 @@ begin
     begin
     If (O.NodeType=Element_NODE) and (O.NodeName='option') then
       begin
-      N:=LowerCase(TDOMElement(o)['name']);
-      V:=TDOMElement(o)['value'];
+      N:=LowerCase(Utf8Encode(TDOMElement(o)['name']));
+      V:=UTF8Encode(TDOMElement(o)['value']);
       Case IndexOfString(N,OptionNames) of
         0 : Options.HideProtected:=TrueValue(v);
         1 : Options.WarnNoNode:=TrueValue(v);
@@ -260,8 +262,8 @@ procedure TXMLFPDocOptions.SaveEngineOptions(Options: TEngineOptions;
       Exit;
     E:=XML.CreateElement('option');
     AParent.AppendChild(E);
-    E['name'] := n;
-    E['value'] := v;
+    E['name'] := Utf8Decode(n);
+    E['value'] := Utf8Decode(v);
   end;
 
   procedure AddBool(const AName: string; B: Boolean);
@@ -298,15 +300,15 @@ Var
 
 begin
   SplitInputFileOption(AInputFile,F,O);
-  AParent['file']:=F;
-  AParent['options']:=O;
+  AParent['file']:=Utf8Decode(F);
+  AParent['options']:=Utf8Decode(O);
 end;
 
 procedure TXMLFPDocOptions.SaveDescription(const ADescription: String;
   XML: TXMLDocument; AParent: TDOMElement);
 
 begin
-  AParent['file']:=ADescription;
+  AParent['file']:=Utf8Decode(ADescription);
 end;
 
 procedure TXMLFPDocOptions.SaveImportFile(const AImportFile: String;
@@ -317,8 +319,8 @@ Var
 
 begin
   I:=Pos(',',AImportFile);
-  AParent['file']:=Copy(AImportFile,1,I-1);
-  AParent['prefix']:=Copy(AImportFile,i+1,Length(AImportFile));
+  AParent['file']:=Utf8Decode(Copy(AImportFile,1,I-1));
+  AParent['prefix']:=Utf8Decode(Copy(AImportFile,i+1,Length(AImportFile)));
 end;
 
 procedure TXMLFPDocOptions.SavePackage(APackage: TFPDocPackage;
@@ -330,9 +332,9 @@ var
   E,PE : TDomElement;
 
 begin
-  AParent['name']:=APackage.Name;
-  AParent['output']:=APackage.Output;
-  AParent['content']:=APackage.ContentFile;
+  AParent['name']:=UTF8Decode(APackage.Name);
+  AParent['output']:=UTF8Decode(APackage.Output);
+  AParent['content']:=UTF8Decode(APackage.ContentFile);
   // Units
   PE:=XML.CreateElement('units');
   AParent.AppendChild(PE);
@@ -388,6 +390,7 @@ begin
     Result:=TMemoryStream.Create;
     P.ParseStream(F,Result);
     Result.Position:=0;
+    TMemoryStream(Result).SaveToFile('/tmp/opts.xml');
   finally
     FreeAndNil(F);
     FreeAndNil(P);
diff --git a/utils/fpdoc/makeskel.lpi b/utils/fpdoc/makeskel.lpi
index 618cdd3503..55d83e4a0a 100644
--- a/utils/fpdoc/makeskel.lpi
+++ b/utils/fpdoc/makeskel.lpi
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
     <Version Value="11"/>
@@ -28,8 +28,9 @@
     </PublishOptions>
     <RunParams>
       <local>
-        <CommandLineParams Value="--package=fpvectorial --input=/home/felipe/Programas/fpctrunk/packages/fpvectorial/src/fpvectorial.pas"/>
+        <CommandLineParams Value="--update --disable-protected --disable-private --emit-class-separator --package=rtl --disable-arguments --disable-function-results --descr=matrix.xml --input=&quot;-Fi../packages/rtl-extra/src/inc  ../packages/rtl-extra/src/inc/matrix.pp &quot; --output=matrix.new.xml"/>
         <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+        <WorkingDirectory Value="/home/michael/docs/"/>
       </local>
       <FormatVersion Value="2"/>
       <Modes Count="1">
@@ -56,18 +57,12 @@
     </Units>
   </ProjectOptions>
   <CompilerOptions>
-    <Version Value="10"/>
+    <Version Value="11"/>
     <Parsing>
       <SyntaxOptions>
         <UseAnsiStrings Value="False"/>
       </SyntaxOptions>
     </Parsing>
-    <Other>
-      <CompilerMessages>
-        <UseMsgFile Value="True"/>
-      </CompilerMessages>
-      <CompilerPath Value="$(CompPath)"/>
-    </Other>
   </CompilerOptions>
   <Debugging>
     <Exceptions Count="2">
diff --git a/utils/fpdoc/mkfpdoc.pp b/utils/fpdoc/mkfpdoc.pp
index e45241e9e1..058577e1fb 100644
--- a/utils/fpdoc/mkfpdoc.pp
+++ b/utils/fpdoc/mkfpdoc.pp
@@ -1,7 +1,7 @@
 unit mkfpdoc;
 
 {$mode objfpc}{$H+}
-
+{$WARN 5024 off : Parameter "$1" not used}
 interface
 
 uses
@@ -270,7 +270,7 @@ begin
     for i := 0 to APackage.Inputs.Count - 1 do
       try
         SplitInputFileOption(APackage.Inputs[i],Cmd,Arg);
-        Cmd:=FixInputFIle(Cmd);
+        Cmd:=FixInputFile(Cmd);
         if FProcessedUnits.IndexOf(Cmd)=-1 then
           begin
           FProcessedUnits.Add(Cmd);