I was going over some very old print code which use to work but now just prints symbols instead of producing a carriage return in the printer out.

a = "ACROSS: "+ chr(13)
g.drawString a, csx,y,xe-10

Thoughts please?

a = "ACROSS: "+ endofline

Not sure. I just tried quick tests on Mac and Windows and it looks to me like the Chr(13) moves the text to the next line, at least when outputting to PDF. Perhaps it’s a local machine printer driver issue?

My test code:

Dim g As Graphics Dim p As PrinterSetup p = New PrinterSetup If p.PageSetupDialog Then g = OpenPrinterDialog(p) If g <> Nil Then g.DrawString("Hello" + Chr(13) + "World", 50, 50) End If End If

Or encoding issue.

When I test this outputting to pdf I get the following

Hi Paul and others, yes the test code works fine. I am using the following

Dim CR As String
CR = Encodings.ASCII.Chr(13)
a = "ACROSS: “+ CR
FOR x = 1 TO ac
a = a + STR(num(x)) + “.” + uppercase(list(acl(x))) +” "

So could the problem be that I am concatenating the chr(13) in amongst a longer string?



foo = ConvertEncoding(<concatenation code here> , Encodings.UTF8)

No Luck Emile, I did this with no change

a = "ACROSS: “+ Chr(13)
FOR x = 1 TO ac
a = a + STR(num(x)) + “.” + uppercase(list(acl(x))) +” "
a = a + chr(13)
dim foo as string
foo = ConvertEncoding(a, Encodings.UTF8)
g.drawString foo,csx+10,y+25,xe-10

The plot thickens a bit. It works fine if I add the words to the crossword via the program interface but if I import a list of words to generate the crossword then the strange characters replace the chr(13)??

Final info, it behaves fine if I import a standard text file but if I extract words from an imported stored dictionary the characters reappear? When I examine the dictionary file breaking the program immediately after import the words look ok??

What is your character ? A black lozange with a question mark in it ?

Yes it is (I could not watch the shared image previously).

So, this case, I resolved using ConvertEncoding.

That case was setting InternetHeader strings into a TextArea…

Edit: removed typos.

You may check ReplaceLineEndings .

Hi Emile, yes it is the diamond with the ? character.

I tried replacelineendings but no luck. If I assign chr(13) to a variable and examine that it looks fine. Something seems to happen when I add it in the loop but only after I have extracted words via a Dictionary ??

Did you try to assign the string to a TextArea ?

You can also display the string using a MsgBox (MsgBox allows you to copy the text as displayed !).

Ultimate test:

Take a brand new project, add a Canvas and draw your text there…

Right. That’s an Encoding issue.

@Martin Fitzgibbons - when you load words from disk or database, are you setting the encoding at all?

Could you show us that code?

It works fine in a new project and the current project soloing as I don’t import the wordlist from the Dictionary.

In the picture you can see I even broke all components of the concatenation into separate variables to examine them and they look ok. But when I put them back together the chr(13) disappears, CR has the correct ASCII code in memory until I do the following
foo = a + CR + b + CR + CR + c + CR + d

I’m curious though… why are you using chr(13) anyway? No current platform uses that as a line delimiter. Linux and macOS use LF and Windows still uses CRLF.

You should also keep in mind that the words are probably not encoded as ASCII. It’s more likely that they’re UTF8 and that might explain why you’re getting funky concatenations here. As Emile stated, you should probably be using the EndOfLine method.

I load the text file as below

Dim fdict As FolderItem
Dim a As String

If dictbuild = False then
dictbuild = True
fdict = GetFolderItem(“Default Dictionary.txt”)
if fdict.Exists then
myDictionary = new ADictionary(fdict)
end if
End if

I suppose that I know, but what code is in ADictionary ?