diff options
-rw-r--r-- | docview/src/HelpFile.pas | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/docview/src/HelpFile.pas b/docview/src/HelpFile.pas index abbb8610..dfe4ac9f 100644 --- a/docview/src/HelpFile.pas +++ b/docview/src/HelpFile.pas @@ -192,6 +192,7 @@ uses // ACLLanguageUnit; fpg_main ,fpg_utils + ,fpg_stringutils ,nvUtilities ,ACLStringUtility ; @@ -393,6 +394,10 @@ end; constructor THelpFile.Create(const aFileName: string); +var + i: integer; + lText: string; + lTopic: TTopic; begin LogEvent(LogObjConstDest, 'THelpFile.Create (file:' + aFileName + ')'); LogEvent(LogParse, 'Helpfile Load: ' + aFileName); @@ -411,6 +416,22 @@ begin ReadFontTableData; ParseFontTable; ReadReferencedFilesTable; + + // Fix text encoding + for i := 0 to TopicCount-1 do + begin + lText := TTopic(TopicList[i]).Title; + // apply encoding conversion + case Encoding of + encUTF8: lText := IPFToUTF8(lText); + encCP437: lText := CP437ToUTF8(lText); + encCP850: lText := CP850ToUTF8(lText); + encIBMGraph: lText := IBMGraphToUTF8(lText); + else + lText := IPFToUTF8(lText); + end; + TTopic(TopicList[i]).Title := lText; + end; except Close; raise; @@ -584,6 +605,7 @@ begin _FontTable, _ReferencedFiles ); + Topic.HelpFile := Self; Topic.Index := EntryIndex; @@ -667,6 +689,7 @@ var pEnd: pByte; pIndexData: pointer; tmpIndexEntry: TIndexEntry; + lText: string; begin LogEvent(LogParse, 'Read index'); _Index := TIndex.Create; @@ -696,6 +719,16 @@ begin if pEntryHeader^.TOCIndex < _Topics.Count then begin + // apply encoding conversion + case Encoding of + encUTF8: lText := IPFToUTF8(EntryText); + encCP437: lText := CP437ToUTF8(EntryText); + encCP850: lText := CP850ToUTF8(EntryText); + encIBMGraph: lText := IBMGraphToUTF8(EntryText); + else + lText := IPFToUTF8(EntryText); + end; + EntryText := lText; tmpIndexEntry := TIndexEntry.Create(EntryText, TTopic(_Topics[pEntryHeader^.TOCIndex]), pEntryHeader^.flags); _Index.Add(tmpIndexEntry); end |