Find carriage return (cr) and line feed (lf) in NOTES fields of Dynamics GP
This is a Epson FX80 dot matrix printer. For those of us who remember RS232 driving these things using DOS or Turbo Pascal then you know that to make it move down a line, then a line feed ASCII character would need sending in the text stream, a char(10).
To make the printer move its print head to the start of the line (left had column) a carriage return would have to be issued, a char(13). This heralded from the mechanical typewriter origins of printers where on the typewriter, you’d have to move a line down and push the carriage to the start of the line again (return the carriage). – Yes I still own a mechanical typewriter…
Although the behaviour could be configured, often with DIP switches, electrical config switches hidden in the printer or using config ESC codes, it was common in computing to have to have a char(10)+char(13) sequence at the end of lines. However it was not uncommon (UNIX) to find just a char(10) alone used.
if it has not be sanitised before injection into the GP database, Dynamics GP notes fields, can have both or one of these characters used. However only char(13) should be used as char(10) gives an ugly block character in the text when displayed in the user interface, for some versions of GP. We use Profad Enhanced notes in place of the default notes window, where the type of line feed character no longer seems to matter.
To see what line endings are present, the output saved from SQL can be viewed in a text (HEX enabled) editor allowing the hex of the file to be viewed, or it can be easier to translate the line feeds and carriage returns into tokens using SQL script like this and view in normal SQL server Management Studio:
REPLACE(CAST(TXTFIELD AS VARCHAR(max)), CHAR(10), '[lf]'),
Where the zeros of NOTEINDX are replaced with the note id of interest and every carriage return will show as [cr] and every line feed as [lf].
Here is an example of the output of this SQL, a bad example with [cr][lf] sequence in the notes
If the fields need cleaning because of blocky characters, then I wrote about this a while back Formatting notes using GP econnect
This wiki has much more info and more detailed information for those who are interested https://en.wikipedia.org/wiki/Newline