Read-only archive of the All About Symbian forum (2001–2013) · About this archive

Problems outputting extended characters into ASCII-File

3 replies · 2,911 views · Started 26 April 2003

Hi,

I�ve tried to use

SETFLAGS KAlwaysWriteASCIIFiles&
IOOPEN(h1%,"Filename.txt",$0122)
REM Opening in BINARY Mode
OutString$="Text Line 1 ���"+CHR$(KCarriageReturn&amp😉+CHR$(KLineFeed&amp😉+"Text Line 2"
IOWRITE (h1%,ADDR(OutString$)+1+KOplAlignment%),LEN(OutString$)
IOOCLOSE(h1%)
CLEARFLAGS KAlwaysWriteASCIIFiles&

and when I�ve looked into the created File "Filename.txt" (ASCII) I�m getting:

Text Line 1: xxx (<- xxx representing 3 times hex value 1A instead of the character ���)
Text Line 2

However, if I use remove the SETFLAGS KAlwaysWriteASCIIFiles& I�m getting
an UNICODE-File with the correct:

Text Line 1: A��
Text Line 2

My problem is now, that I want to write the german extended characters right (e.g. �=196 dez)
AND that I want to write in ASCII-mode instead of UNICODE-Mode.

I�ve tried to use BINARY Mode (altering value $122 in Line 2 to $102) for output,
but here SETFLAGS KAlwaysWriteASCIIFiles& don�t seem to work, and
I haven�t success outputting a carriage return (CHR$13) and a linefeed (CHR$10)
in this BINARY Mode.

Luzie

Hi Luzie !
had same problem here, want to write a runtime tracing-tool to write some vars and messages to a ascii-file. to run on PC-emulator or symbian device.

attached you will find my workaround.
some codelines "unicode to AScii converter" found in vCal a tool from http://www.freepoc.org - (thanks to Malcolm Bryant)

HTH
Gerhard from Salzburg

Hi,

thnaks for your reply / program.

I�ll have a look at it in my next spare time,
and then reply here. Yet I used another (very slow)
workaround, which I then will also post here.

Regards,

Luzie

Hi,

I think the best option is to use binary mode and instead use the Buffer.opx and the Convert.opx for text handling.

When using binary mode, you should *not* use
SETFLAGS KAlwaysWriteASCIIFiles&

When you have created and manipulated your binary buffer, just use

IOmode%=KIOModeReplace% OR KIOFormatBinary% OR KIOAccessUpdate%
IOOPEN(hOutFile%,Location$+KOutFileName$,IOmode%)
IOWRITE(hOutFile%,pBuffer&,BufferSize&amp😉

Since it is Ascii, BufferSize& should be equal to BufferLen&

Check also dpNote 18 and 19 for some further ideas about conversion and binary buffer handling of text.

www.dp.com.my [dpNotes]

cheers
Martin