News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Replacing CRLF in a print file

Started by allynm, February 05, 2010, 02:35:11 PM

Previous topic - Next topic

allynm

Hi everyone,

Here is one of those odd bits that make a beginner's life in coding interesting.  I am trying to read a text file that has CRLF's in it.  I want to print the text file using TextOut and the usual calls to StartPage, StartDoc, etc.  I use a couple msvcrt ( mbrtowc() ) calls to do the character conversions from char to wchar (TCHAR) so that TextOut will function.  The problem is the doggone CRLF's.  I can't figure out how to replace them with their wchar "blank" equivalents so that the printer doesn't try to print them too.  They show up in the printed output as two null-symbols and they are a nuisance.

I have a strong hunch that you folks have solved this problem.  I can't find anything about it on the Forum however.

Thanks as always,

Mark Allyn

hutch--

Mark,

If you need to chomp it line by line there is a fast in place tokeniser in the MASM32 library "ltok". Its in the help file. As long as its not too big, load it into memory in one disk read then tokenise it into an array of text lines.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

allynm

Hello Hutch -

Thansk for the guidance.  I will try ITOK.  Will report back on my experience.

Regards,

Mark

jj2007

> The problem is the doggone CRLF's.  I can't figure out how to replace them with their wchar "blank" equivalents so that the printer doesn't try to print them too.

Why don't you just insert a double zero to delimit the text you are printing?

sinsi

Surely if you send it to a printer as text it would work?
CR is carriage return, back to the first column
LF is line feed, down 1 row without altering the column

You could try replacing the CR (0dh) with a space, then the C function might like it (isn't 0ah the same as 0dh,0ah to C?)
Light travels faster than sound, that's why some people seem bright until you hear them.