WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Binary Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Convert to UTF-8

 Keywords: Unicode ANSI BOM BinaryConvert Code Page 65001 

The UTF-8 BOM is usually not needed but some applications like Notepad use it so, mostly for the curious, here is a BOMed version
; Add 3 leading spaces for the BOM
strAnsi = "   ":"Hello World"

; Convert to UTF-8
hBuff = BinaryAlloc((StrLen(strAnsi)+1)*2)
BinaryPokeStr(hBuff, 0, strAnsi)
BinaryConvert(hBuff, 0, 3, 0, 0)
BinaryConvert(hBuff, 3, 0, 65001, 0)

;  Add UTF-8 BOM and write to file
BinaryPokeHex(hBuff, 0, "EF BB BF")
BinaryWrite( hBuff, DirScript():"UTF-8withBOM.txt" )


Article ID:   W17680
Filename:   Convert to UTF-8.txt
File Created: 2012:07:12:12:42:32
Last Updated: 2012:07:12:12:42:32