Bob Bryce wrote:
> Well I've played around with Robert Pures's "munger" code and
> I can get it to write RTF code in the place of SFM ags (Standerd
> Format Markers)
> But now instead of a few questions at a time as I work on my program,
> I have dozens if I were to replace my complicated INSTR$ stuff
> with the munger code.
> 1. Unicode text in my source file is still corrupted when it is
> written to the output file.
I don't think so. More likely, the app that you use to open the file
is using the wrong text encoding (perhaps MacRoman a.k.a. Mac OS
Roman). You'll need to set the app's preferences to open a text file
as UTF-8 instead of guessing. TextEdit.app's setting "Automatic", for
example, would be better named "Often wrong".
> The first thing written to the file is RTFid$="{
> tf1\mac\deff2 "
> Then comes things like a font table, a style listing, header and
> footer information, page layout definitions and so on AND THEN
> the actual text body is processed to replace the SFM tags with
> RTF strings. LAST of all a curly bracket has to be written at the
> end of the file to match the initial curly bracket and define the
> whole thing as an RTF document.
Munger() lends itself to wrapper functions like these:
local mode
local fn PrependToHandle( h as Handle, insertMe as Str255 )
'~'1
call Munger( h, 0, 0, 0, @insertMe + 1, insertMe[0] )
end fn
local mode
local fn AppendToHandle( h as Handle, insertMe as Str255 )
'~'1
call Munger( h, fn GetHandleSize( h ), 0, 0, @insertMe + 1,
insertMe[0] )
end fn
You may decide, though, to read your text file into a container
variable (a disguised Handle) instead of an openly visible Handle as
in my posted demo.
Then you can write code like:
gTheTextContainer = "STARTING_STUFF" + gTheTextContainer
gTheTextContainer = gTheTextContainer + "ENDING_STUFF"
and use instr() to search the container.
Robert P.
Attachments: