erezlevi Posted January 10, 2008 Share Posted January 10, 2008 hi, can anyone help we with converting a txt file from ANSI to UNICODE, what is the method on doing this ? Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 10, 2008 Share Posted January 10, 2008 hi, can anyone help we with converting a txt file from ANSI to UNICODE, what is the method on doing this ? It's very deep and complicated, but if you want to wade into it: $sFileA = "C:\Temp\ANSI_Test.txt" $sFileU = "C:\Temp\UTF_Test.txt" $hFile = FileOpen($sFileU, 2 + 32) ; 2 = overwrite, 32 = UTF16 Little Endian FileWrite($hFile, FileRead($sFileA)) FileClose($hFile) MsgBox(64, "Done", "Ta Da!!!") 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 Link to comment Share on other sites More sharing options...
dleigh Posted April 15, 2012 Share Posted April 15, 2012 Related/similar problem (yes I know this is an old thread, but perhaps putting them together makes sense for the next guy/gal searching): I have a file that is produced with the DOS "sort" command and it's in codepage 850. No FileOpen choice seems to read it correctly. Does AutoIt have a way to deal with this or does someone else know a way to deal with either getting DOS (Windows 7 in this case) to output it differently or to convert it afterwards? Thank you! Link to comment Share on other sites More sharing options...
Jury Posted April 15, 2012 Share Posted April 15, 2012 (edited) dleigh,perhaps this will help:or lok at this:http://waterlan.home.xs4all.nl/dos2unix/dos2unix_beta.htm#conversion_modesit has: Convert from DOS CP850 to Unix Latin-1opensource: http://sourceforge.net/projects/dos2unix/ Edited April 15, 2012 by Jury Link to comment Share on other sites More sharing options...
jchd Posted April 15, 2012 Share Posted April 15, 2012 (edited) Can you try this and report success/failure? ; read old DOS CP850 file Local $hdl = FileOpen("Dos850.txt", 16) ; read in binary mode Local $binText850 = FileRead($hdl) FileClose($hdl) Local $text = __CodepageStructToString($binText850) ; from there, $text is a genuine copy of the Dos file, but now using native AutoIt Unicode encoding. ConsoleWrite($text & @LF) Func __CodepageStructToString($tText) Local $aResult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", 850, "dword", 0, "struct*", $tText, "int", -1, _ "ptr", 0, "int", 0) If @error Then Return SetError(1, @error, "") ; Dllcall error Local $tWstr = DllStructCreate("wchar[" & $aResult[0] & "]") $aResult = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", "uint", 850, "dword", 0, "struct*", $tText, "int", -1, _ "struct*", $tWstr, "int", $aResult[0]) If @error Then Return SetError(2, @error, "") ; Dllcall error Return DllStructGetData($tWstr, 1) EndFunc Edit: I saw the previous post after sending mine. My ad hoc function is equivalent to the WinAPI call. Edited April 15, 2012 by jchd 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