Sign in to follow this  
Followers 0
cookiemonster

FileWrite Issue with UTF8

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



I tried that but $FO_APPEND + $FO_UTF8_NOBOM does not change the line in the file, and $FO_OVERWRITE  + $FO_UTF8_NOBOM just leaves me with a blank file

Share this post


Link to post
Share on other sites

Sorted it but have to run, will post working code tomorrow

Share this post


Link to post
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
Sign in to follow this  
Followers 0