Skip to Content
avatar image
Former Member

FileWrite

Regards.

I use:

li_file = FileOpen (ls_path + ls_file, LineMode!, Write!, LockReadWrite!, Replace!)

When i write:

ls_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><name>QUÍMICO'

if FileWrite (li_file, ls_xml) = -1 then

  MessageBox("Error", "error", StopSign!)

end if

The result is: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><name>QU΍ICO

But if i write:

ls_xml = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><name>QUÍMICO"

The result is: <?xml version='1.0' encoding='UTF-8' standalone='yes'?><name>QUÍMICO

WHY???

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 08, 2015 at 01:37 AM

    In the FileOpen you could try adding encoding EncodingUTF8!

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Victor;

        FWIW: Have you tried the FileWiteEX ( ) method instead?   I have not encountered your Unicode issue but .... I have not used the old FileWrite ( ) method in over a decade.

      BTW: Since PB 10 (being Unicode) I only use  EncodingUTF16LE! within my PB applications and EncodingUTF8! when sending data to external applications. Note that WindowsVista and higher is all UTF-16LE.

      Regards ... Chris

  • avatar image
    Former Member
    Jan 08, 2015 at 07:24 PM

    Hi Victor,

    I used your exact code with both FileWrite and FileWriteEx and did not see a problem.  I'm using PowerBuilder 12.5.2 build 5703.

    Ted Zimmerman


    Add comment
    10|10000 characters needed characters exceeded