Importing from CSV file, what encoding should I use to conserve Spanish and German special characters?

Tag: excel , csv , character-encoding , navision Author: zw_angel Date: 2013-09-16

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?

Other Answer1

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