576i
576i

Reputation: 8382

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

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?

Upvotes: 1

Views: 1447

Answers (1)

Erik P. Ernst
Erik P. Ernst

Reputation: 98

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

Upvotes: 1

Related Questions