same problem. But when I changed $0123 in the second ioopen to $0022, it did not crash. But this does not still write the correct characters into file. Your german characters are all written as 0x1A. I had the same problem when code page was not set to correct one with unicode files. But even adding codepage selection to your program did not help:
rem select proper codepage for unicode conversion
CP&=CVCharSetUid&😞6) rem iso8859-1
CVSelectCharSet😞CP&😉
I propose that you open your file in binary mode, then convert from string to ascii and write that into file, with scheme like this (maybe typos etc):
local buf1&(256),text$(255),buf1len&
rem select proper codepage for unicode conversion
CP&=CVCharSetUid&😞6) rem iso8859-1
CVSelectCharSet😞CP&😉
IF IOOPEN(hw%,"FILE.TXT",$0102) rem binary, write,truncate
print "Error opening file"
get
stop
ENDIF
text$="��"
buf1len& = len(text$)
CVFromUnicode😞buf1&,buf1len&,text$)
IOWRITE(hw%,ADDR(buf1&😉,buf1len&😉
IOCLOSE(hw%)
Here's a program for you to dump the files as hex.
rem file read & dump hex
DECLARE EXTERNAL
INCLUDE "CONST.OPH"
INCLUDE "CONVERT.OXH"
include "system.oxh"
PROC Main:
local F$(255),CP&
global ldata%(80)
LOCAL h%,String$(KMaxStringLen%),ret%,dia%
local n%,addr%,r$(2)
rem select proper codepage for unicode conversion
CP&=CVCharSetUid&😞6) rem iso8859-1
CVSelectCharSet😞CP&😉
rem FONT KFontArialBold13&,KgStyleNormal%
f$ = "d:\FILENAME.TXT"
do
f$=SyOpenFileDialog$😞f$,0,0,0)
if f$ = ""
return
endif
print "file:",f$
IOOPEN(h%,F$,$0400+$0200) rem open in random-access mode (ioseek)
addr% = 0
DO
n%=0
Ret% = 0
Ret%=IOREAD(h%,ADDR(ldata%(1)),16)
if Ret%>0
print right$("0000000"+hex$(addr%)+":",9), : addr% = addr% + Ret%
while n%<Ret%
print right$("0"+hex$(peekb(ADDR(ldata%(1))+n%)),2),
n% = n% + 1
endwh
n%=0
while n%<Ret%
if peekb(ADDR(ldata%(1))+n%) >= 32
print CVUnicode$😞ADDR(ldata%(1))+n%,1);
else
print ".";
endif
n% = n% + 1
endwh
print
else
print "******* EOF, press q to quit *******"
endif
r$=get$
until r$ = "q"
ioclose(h%)
until f$=""
ENDP
BTW. Some of the text has changed to those "Emoticons" above, I don't know why? The character sequence (2 characters) is : and (, which "looks" quite logical...