Jump to content

FileWrite Issue with UTF8


Recommended Posts

Hey all,

Ive got an issue writing to a UTF8NOBOM file.

my code is below, its succesful on opening and closing the file, but it fails to write to it despite using '$FO_UTF8_NOBOM (256) = Use Unicode UTF8 (without BOM) reading and writing mode.'

I have also tried: $FO_APPEND + $FO_UTF8_NOBOM which does not change the line in the file, and $FO_OVERWRITE  + $FO_UTF8_NOBOM which just leaves me with a blank file

Anyone got any ideas?

#include <File.au3>

$File = "C:\file.m"
$filehandle = FileOpen($File, $FO_UTF8_NOBOM)
        $FileContent = FileRead($filehandle, -1)
        FileClose($filehandle)
        $Find = "DO NOT USE"
        $Replace = "This Should Never Be Used"
        $filehandle = FileOpen($File, $FO_UTF8_NOBOM)
        $FileContent = StringReplace($FileContent, $Find, $Replace)
        $A = FileWrite($filehandle, $FileContent)
        $B = FileClose($filehandle)
        
Msgbox (4096, "QA", $filehandle & @crlf & $A & @crlf & $B)
Edited by cookiemonster
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...