cookiemonster Posted November 11, 2014 Share Posted November 11, 2014 (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 November 11, 2014 by cookiemonster Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 11, 2014 Share Posted November 11, 2014 Default is read mode so what you have now is read as $FO_UTF8_NOBOM+$FO_READ. You must add $FO_APPEND or $FO_OVERWRITE .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
cookiemonster Posted November 11, 2014 Author Share Posted November 11, 2014 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 Link to comment Share on other sites More sharing options...
cookiemonster Posted November 11, 2014 Author Share Posted November 11, 2014 Sorted it but have to run, will post working code tomorrow Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now