简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM