summaryrefslogtreecommitdiff
path: root/docview/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2012-02-13 09:28:30 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2012-02-13 09:28:30 +0200
commit581b4f7392fe5c30818b18d2f642a285c7da5c78 (patch)
tree66aa6ed8eae7c0b23c8f3bd7a8542b554758fd84 /docview/src
parent82f580f0fe0dc24d9a260159e135df89e215fa4d (diff)
downloadfpGUI-581b4f7392fe5c30818b18d2f642a285c7da5c78.tar.xz
TOC and Index entries now in UTF-8 encoding
I converted the topic content to UTF-8 before displaying it, but I never did so for the TOC text or the Index text. This patch should fix this problem. TODO: Searching for umlauts still is a problem.
Diffstat (limited to 'docview/src')
-rw-r--r--docview/src/HelpFile.pas33
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