Create file into UTF-8

nromainnromain Member Posts: 57
Hello and happy end of year,

I try to generate a file from navision (3.70) encoding in UTF-8 but i don't know how. I cannot use an external program. The file must be directly generate into UTF-8. Could you help me?

Thank you.

Regards,

Comments

  • garakgarak Member Posts: 3,263
    you can create in C# a DLL which convert your file in UTF-8.
    Google for this, maybe there exist a freeware dll.
    Do you make it right, it works too!
  • garakgarak Member Posts: 3,263
    Test this from the download section
    Do you make it right, it works too!
  • nromainnromain Member Posts: 57
    Thank you for your reply, but i want to directly generate the file into UTF-8. I cannot pass trough an external way.
  • niscoxniscox Member Posts: 15
    You can do this with an automation of type 'Microsoft ActiveX Data Objects 2.8 Library'.Stream.

    something like this:
    CREATE(adostream);
    adostream.Open;
    adostream.Charset('UTF-8');
    
    adostream.WriteText('testtext');
    adostream.SaveToFile('c:\text.txt');
    
    adostream.Close;
    
  • nromainnromain Member Posts: 57
    Hello,

    i have not try this solution but a collegue show me another one that works :

    Create the file you want to export into UTF-8 into a ANSI one. Create another file in binary this time (TEXTMODE = false) and forced the 3 beginning characters to be in hexadecimal : EF BB BF. Then open your first file with textmode = false and read each line and copy them into the second file.

    The second file will be considered as UTF-8 (with EF BB and BF value) and contains all datas you want to export.

    Best regards,
  • niscoxniscox Member Posts: 15
    Interresting one, but this works only if your text contains nothing then good old 7-bit ASCII. Any Character above 7F (127) will result in a garbled textfile.
Sign In or Register to comment.