Borje Posted April 26, 2021 Author Share Posted April 26, 2021 Thanks vip your example works perfect I see what you have done for changes in the code to have it to work. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 26, 2021 Developers Share Posted April 26, 2021 13 minutes ago, VIP said: Result.htm is a new file to be burned, not an existing file! Yes I know .... and need that when you want to compare the results ... right? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Trong Posted April 26, 2021 Share Posted April 26, 2021 8 minutes ago, Jos said: Yes I know .... and need that when you want to compare the results ... right? I really don't understand what you mean !. I have tried it, although the code works but I don't understand why writing UTF-8 is in error. Although the test function returned UTF-8 with the successful file !. expandcollapse popupGlobal $dat = @YEAR & "-" & @MON & "-" & @MDAY & " - " & " " & @HOUR & ":" & @MIN Global $namn = "Unicode problem's" Global $Test1 = " Test1 = Å Ä Ö" ; should be Test1 = Å Ä Ö Global $test2 = "Test2 = å ä ö" ; Should be Test2 = å ä ö Global $dag = "Måndag Lördag Söndag" ; Should be Måndag, Lördag Söndag Global $sInputFile = @ScriptDir & "\Mall.htm" Global $sOutputFile = @ScriptDir & "\Result.htm" _Write_Example_HTML($sInputFile) ; Write the example file! Global $hFileIN = FileOpen($sInputFile, 0 + 16384) ; $FO_FULLFILE_DETECT (16384) Global $hFileOUT = FileOpen($sOutputFile, 2 + 16384) ; $FO_OVERWRITE (2) While 1 Local $line = FileReadLine($hFileIN) If @error = -1 Then ExitLoop If StringInStr($line, "%N") Then $line1 = StringReplace($line, "%N", $namn) FileWriteLine($hFileOUT, $line1) ElseIf StringInStr($line, "%Dag") Then $line1 = StringReplace($line, "%Dag", $dag) FileWriteLine($hFileOUT, $line1) ElseIf StringInStr($line, "%Dat") Then $line1 = StringReplace($line, "%Dat", $dat) FileWriteLine($hFileOUT, $line1) ElseIf StringInStr($line, "%Test1") Then $line1 = StringReplace($line, "%Test1", $Test1) FileWriteLine($hFileOUT, $line1) ElseIf StringInStr($line, "%Test2") Then $line1 = StringReplace($line, "%Test2", $test2) FileWriteLine($hFileOUT, $line1) Else FileWriteLine($hFileOUT, $line) EndIf WEnd FileClose($hFileIN) FileClose($hFileOUT) ShellExecute($sInputFile) ShellExecute($sOutputFile) ConsoleWrite("- FileGetEncoding Input File: " & $sInputFile & @CRLF & '->' & _FileGetEncoding($sInputFile) & @CRLF) ConsoleWrite("- FileGetEncoding Output File: " & $sOutputFile & @CRLF & '->' & _FileGetEncoding($sOutputFile) & @CRLF) Func _Write_Example_HTML($inputFilePath = "eg.htm") Local $iHTMLcontent = '<!DOCTYPE html>' & @CRLF & '<html>' & @CRLF & '<head>' & @CRLF & '<meta charset="UTF-8">' & @CRLF & '<title></title>' & @CRLF & '</head>' & @CRLF & '<table cellpadding=5 cellspacing=5 border=2 bordercolor=#666666 bgcolor="#C0C0C0">' & @CRLF & '<tr>' & @CRLF & '<td align=center colspan="2" bgcolor="#33CCCC">' & @CRLF & '<b>' & @CRLF & '<font size="5">%N</font><br>' & @CRLF & '<font color=#000080</font>' & @CRLF & '</b>' & @CRLF & '</td>' & @CRLF & '</tr>' & @CRLF & '<tr>' & @CRLF & '<td align=center bgcolor="#E41B17">' & @CRLF & '<b><font size="3" color="#FFFFFF"> å ä ö</font><br>' & @CRLF & '<b><font size="3" color="#FFFFFF"></font></b>' & @CRLF & '</td>' & @CRLF & '<td align=center bgcolor="#E41B17">' & @CRLF & '<b><font size="3" color="#FFFFFF"' & @CRLF & '<font color="#FFFFFF">%Dag</font><br>' & @CRLF & '<font color="#FFFFFF">%Dat</font>' & @CRLF & '</td>' & @CRLF & '</tr>' & @CRLF & '<tr>' & @CRLF & '<td align=right bgcolor="#33CCCC"color="#FFFFFF">Å Ä Ö</td>' & @CRLF & '<td align=left bgcolor="#33CCCC">' & @CRLF & '<font color="#000000">%Test1</font>' & @CRLF & '</tr>' & @CRLF & '<tr>' & @CRLF & '<td align=right bgcolor="#33CCCC">å ä ö</td>' & @CRLF & '<td align=left bgcolor="#33CCCC">' & @CRLF & '<font color="#000000">%Test2</font>' & @CRLF & '</tr>' & @CRLF & '<tr>' & @CRLF & '</table>' & @CRLF & '</body>' & @CRLF & '</html>' Local $hOpen = FileOpen($inputFilePath, 2 + 16384) ; $FO_FULLFILE_DETECT (16384) ; $FO_OVERWRITE (2) FileWrite($hOpen, $iHTMLcontent) Return (FileExists($inputFilePath) And FileClose($hOpen) > 0) EndFunc ;==>_Write_Example_HTML Func _FileGetEncoding($iFile) Local $Encoding = FileGetEncoding($iFile) If ($Encoding = 32) Or ($Encoding = 1024) Then Return "[32] UTF16 Little Endian" If ($Encoding = 64) Or ($Encoding = 2048) Then Return "[64] UTF16 Big Endian." If ($Encoding = 128) Then Return "[128] UTF8 (with BOM)." If ($Encoding = 256) Then Return "[256] UTF8 (without BOM)." Return "[512] ANSI" EndFunc ;==>_FileGetEncoding Regards, Link to comment Share on other sites More sharing options...
jchd Posted April 26, 2021 Share Posted April 26, 2021 Switch to UTF-8 file encoding for the source, add a space anywhere then delete it and save the source. Best is to force UTF8 encoding for all source files. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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