1

I am importing from an Excel/OpenOffice generated CSV file into Navision (Classic Client NAV2009) with this code.

MyFile.Textmode(TRUE);
MyFile.OPEN('c:\temp\test.csv');
MyFile.READ(MyLine); (Text field);
MyFile.CLOSE;
CLEAR(MyRec);
MyRec.Text1 := MyLine;
MyRec.Insert;
COMMIT;

test.cvs is an export from text.xls and has this single line:

ABC äöüßÄÜÖ éèÑñ

What encoding should I use when saving this file from xls to csv so the special characters arrive in the Navision record unharmed?

576i
  • 7,579
  • 12
  • 55
  • 92
  • UTF-8?, or possibly try to read the text as an ADODB stream? – David Zemens Oct 02 '13 at 16:12
  • 1
    I've tried UTF-8 and lost some, like the Ñ. Navision documentation expects ASCII input there seems no exeption to that. Not sure how I could use ADODB in Navision – 576i Oct 02 '13 at 16:19

1 Answers1

1

NAV correctly expects ASCII inputs. So what you need to do is convert it from ANSI to ASCII. Applied to your code above it will be: MyRec.Text1 := AsciiFunction.Ansi2Ascii(MyLine);

Most NAV developers have this function in their "toolbox", but if you don't then you can find it here: http://dynamicsuser.net/files/storage/extra/nav/ascii_function.txt

Erik P. Ernst
  • 98
  • 1
  • 7