Sign in to follow this  
Followers 0
lsakizada

How to write UTF-8 file Without BOM

3 posts in this topic

I have the script bellow that convert Unicode to UTF-8 file.

I need the UTF-8 file to be save with no BOM

can you help please?

if $CmdLine[0] <> 2 then 
    MsgBox(0,0,"Uses: U2UTF8 'Path to Source Unicode File' 'Path to Destination UTF-8 File' ")
    exit
EndIf
    
Dim $UnicodeFile    = $CmdLine[1]
Dim $UTF8FILE      = $CmdLine[2]    

$File1 = FileOpen($UnicodeFile, 0); 
$Unicode = FileRead($File1, FileGetSize($UnicodeFile))
FileClose($File1)

$file = FileOpen($UTF8FILE, 128+2)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
FileWrite($file, $Unicode)
FileClose ($file)

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites



I have the script bellow that convert Unicode to UTF-8 file.

I need the UTF-8 file to be save with no BOM.

Amazing... I need the same thing. Here is my script:

$i = $CmdLine[1]

$j1 = FileOpen ($i, 128)
$k = FileRead ($j1)
$l = StringReplace ($k, @CRLF, @LF)
FileClose ($j1)

$j2 = FileOpen ($i, 130)
FileWrite ($j2, $l)
FileClose ($j2)

My script is for changing Windows line endings into Unix line endings, and it works except for two things:

1. It adds a BOM

2. It doesn't save as UTF8

The script works if you compile it and then drag and drop the file onto the EXE file (the result replaces the original file).

Anyone found a simple way to remove the BOM yet? Is there a macro code for the BOM so that one can simply remove it?

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