Sign in to follow this  
Followers 0
bentom

"Byte Order Mark" in UTF8 Coded file

7 posts in this topic

Hi,

a question regarding to Unicode.

with the code

FileOpen($PlaylistFile, 2 + 8 + 128)

you create a file which is UTF8 coded but with the "byte order mark". Unfortunatelly the Software which reads the playlistfile needs the coding without "BOM". Does anybody know how to get a proper coding.

Regards

Alex

Share this post


Link to post
Share on other sites



Hi again,

I found a texteditor that can convert the file into UTF8 w/o BOM. Unfortunatelly this has no scripting engine and has to be done manually. The only topic here in the forum I found was form 2007 and there was no support for UTF8 w/o BOM. I use the release 3.2.12.1 from June 2008. I would update if this is now supported.

Anyone who has information on this?

Regards,

Alex

Share this post


Link to post
Share on other sites

Hi,

a question regarding to Unicode.

with the code

FileOpen($PlaylistFile, 2 + 8 + 128)

you create a file which is UTF8 coded but with the "byte order mark". Unfortunatelly the Software which reads the playlistfile needs the coding without "BOM". Does anybody know how to get a proper coding.

Regards

Alex

See if this helps:

;1.
$sPlaylistFile = @DesktopDir & "\PlayListVer1.txt"

$hFile = FileOpen($sPlaylistFile, 2 + 8 + 128)
FileWrite($hFile, "Hey hey")
FileClose($hFile)

;2.
$sPlaylistFile = @DesktopDir & "\PlayListVer2.txt"

$hFile = FileOpen($sPlaylistFile, 2 + 8 + 16)
FileWrite($hFile, StringToBinary("Hey hey", 4))
FileClose($hFile)

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Hi,

thank you very much for your answer. Unfortunatelly not. The format I get is ANSI. But no UTF8 w/o BOM.

I checked this with Notepad++

Any other ideas, or does Autoit not support this coding

Regards,

Alex

Share this post


Link to post
Share on other sites

Check out the _WinAPI_CreateFile() example in the UDF Help-File, should be able to do what you want. MY research came up with that it's capable of writing unicode and BOM has to be create explicitly... but of course I could be wrong :)....

Share this post


Link to post
Share on other sites

Hi,

thank you very much for your answer. Unfortunatelly not. The format I get is ANSI. But no UTF8 w/o BOM.

I checked this with Notepad++

Any other ideas, or does Autoit not support this coding

Regards,

Alex

You are jumping to conclusions. The only difference between those two is BO mark.

See this butterfly from my sig. Run:

;1.
$sPlaylistFile = @DesktopDir & "\PlayListVer1.txt"

$hFile = FileOpen($sPlaylistFile, 2 + 8 + 128)
FileWrite($hFile, ChrW(440) & ChrW(821) & ChrW(801) & ChrW(1244) & ChrW(821) & ChrW(808) & ChrW(772) & ChrW(439))
FileClose($hFile)

;2.
$sPlaylistFile = @DesktopDir & "\PlayListVer2.txt"

$hFile = FileOpen($sPlaylistFile, 2 + 8 + 16)
FileWrite($hFile, StringToBinary(ChrW(440) & ChrW(821) & ChrW(801) & ChrW(1244) & ChrW(821) & ChrW(808) & ChrW(772) & ChrW(439), 4))
FileClose($hFile)

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Hi,

thank you very much for your answer. Unfortunatelly not. The format I get is ANSI. But no UTF8 w/o BOM.

I checked this with Notepad++

There is already another example from trancexx, but I was wondering why you used Notepad++ to check the format. I ran this mod to trancexx's demo to verify it for my own education:
;1.
$sPlaylistFile = @DesktopDir & "\PlayListVer1.txt"
$hFile = FileOpen($sPlaylistFile, 2 + 8 + 128)
FileWrite($hFile, "Hey hey")
FileClose($hFile)
$hFile = FileOpen($sPlaylistFile, 16)
$bData = FileRead($hFile)
FileClose($hFile)
ConsoleWrite("$bData = " & $bData & @LF)

;2.
$sPlaylistFile = @DesktopDir & "\PlayListVer2.txt"
$hFile = FileOpen($sPlaylistFile, 2 + 8 + 16)
FileWrite($hFile, StringToBinary("Hey hey", 4))
FileClose($hFile)
$hFile = FileOpen($sPlaylistFile, 16)
$bData = FileRead($hFile)
FileClose($hFile)
ConsoleWrite("$bData = " & $bData & @LF)

The output is:

>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Scripts\Test1.au3"    
$bData = 0xEFBBBF48657920686579
$bData = 0x48657920686579

Compare the BOM here.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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