Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!decwrl!pyramid!voder!apple!darin From: darin@Apple.COM (Darin Adler) Newsgroups: comp.sys.mac.programmer Subject: Re: TWO Byte Characters, SysEnvirons -- Message-ID: <8318@apple.Apple.Com> Date: 15 Apr 88 07:45:48 GMT References: <742@unioncs.UUCP> <226000007@uxe.cso.uiuc.edu> Reply-To: darin@apple.UUCP (Darin Adler) Organization: Apple Lines: 33 In article <226000007@uxe.cso.uiuc.edu> leonardr@uxe.cso.uiuc.edu writes: > > shinberd@unioncs.UUCP(Dave Shinberg) writes in comp.sys.mac.programmer > >How to put characters into a plain text file. > > > After some time I've > >narrowed the problem down to the fact that a character occupies TWO BYTE > >in MPW Pascal 2.0. Since the program is only intended to be used in English > >I have no need for this. It also appears that some aplications such MPW itself > >does not recognize two byte characters in a text file. You are confusing tyo-byte international characters with the fact that MPW Pascal allocates 2 bytes for a CHAR variable on the stack. CHARs occupy two bytes because of Pascal stack conventions. This is discussed in the "Using Assembly Language" chapter of Inside Mac Vol. I. If you want to write characters to a text file you should only write a single byte for each character. A call to write a single character to a file would look like this: VAR fileRefNum: INTEGER; character: CHAR; buffer: Ptr; count: LONGINT; error: OSErr; {assumes that a file is already open, and its refNum is fileRefNum} character := 'Z'; {write a Z to the file} buffer := Ptr(ORD(@character)+1); {point to the low-order byte} count := 1; {write one byte} error := FSWrite(fileRefNum, buffer, count); -- Darin Adler, Apple Computer AppleLink:Adler4 UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin CSNET: darin@Apple.com