Hi
Is it possible write UTF-8 insted of UTF-16,
using output = FileOpen("\\topdanmark\datadfs\alle\moc\user.xml","write",@TRUE)
THANKS
One way I have used is by means of an ADO Stream. The concept is shown here:
http://www.tek-tips.com/viewthread.cfm?qid=1392917 (http://www.tek-tips.com/viewthread.cfm?qid=1392917)
There may be examples in the Tech Database. Otherwise, this may help
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Strings+Convert~To~UTF-8.txt (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Strings+Convert~To~UTF-8.txt)
Quote from: moc on March 18, 2015, 01:09:26 AM
Hi
Is it possible write UTF-8 insted of UTF-16,
using output = FileOpen("\\topdanmark\datadfs\alle\moc\user.xml","write",@TRUE)
THANKS
Pick your poison.
; Strange but true. You need to make sure
; your output starts as UTF-16.
strAnsi= 'Hello World'
strUnicode = ChrStringToUnicode(strAnsi)
; No BOM in UTF-8 using FileOpen
nPrvCp = ChrSetCodepage(65001)
output = FileOpen(DirScript():"UTF-8.txt","write",@False) ;\\topdanmark\datadfs\alle\moc\user.xml
FileWrite(output, strUnicode)
FileClose(output)
ChrSetCodepage(nPrvCp)
;; OR...
; No BOM version in UTF-8 using BinaryWrite
hBuff = BinaryAlloc(StrByteCount(strUnicode,-1)+2)
nLen = BinaryPokeStrW(hBuff, 0, strUnicode)
BinaryConvert(hBuff, 3, 0, 65001, 0)
BinaryWrite( hBuff, DirScript():"UTF-8NoBOM.txt" )
;; OR...
; BOMed version in UTF-8 using BinaryWrite
hBuff2 = BinaryAlloc(4 + nLen)
BinaryPokeHex(hBuff2, 0, "EF BB BF")
BinaryCopy( hBuff2, 3, hBuff, 0, nLen)
BinaryWrite( hBuff2, DirScript():"UTF-8withBOM.txt" )
BinaryFree(hBuff)
BinaryFree(hBuff2)
Thanks for your advises.
I found a RECODE program, that can change a files codepage
http://docs.ixperion.smartsite.nl/?nr=31111 (http://docs.ixperion.smartsite.nl/?nr=31111)
The above script works just fine and even lowly Notepad can convert a file.