hoangthi Posted December 5, 2008 Share Posted December 5, 2008 Please help me!!! I Can't use SQLite UTF-8. i have code autoit3 below: #include <SQLite.au3> #include <SQLite.dll.au3> Local $hQuery, $aRow, $sMsg _SQLite_Startup () If @error > 0 Then MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!") Exit - 1 EndIf _SQLite_Open (); Open a :memory: database If @error > 0 Then MsgBox(16, "SQLite Error", "Can't Load Database!") Exit - 1 EndIf _SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);"); CREATE a Table _SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','Không gì quý hơn độc lập tự do');"); INSERT Data _SQlite_Query (-1, "SELECT c FROM aTest ORDER BY a;", $hQuery); the query While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK $sMsg &= $aRow[0] WEnd _SQLite_Exec (-1, "DROP TABLE aTest;"); Remove the table MsgBox(0,"SQLite","Get Data using a Query : " & $sMsg ) MsgBox(0,"SQLite","Data input :Không gì quý hơn độc lập tự do") _SQLite_Close () _SQLite_Shutdown () I user windows Xp pro, font Tahoma. Plzzz !!! help me !! Link to comment Share on other sites More sharing options...
picaxe Posted December 5, 2008 Share Posted December 5, 2008 Works for me. Where does it fail for you ? Link to comment Share on other sites More sharing options...
KaFu Posted December 5, 2008 Share Posted December 5, 2008 (edited) Hmmm, tested the code and for me the input looks like the output... but maybe you refer to the three questionmarks, which might in fact be other letters my computer cannot display. Eventually the PRAGMA command helps... #include <SQLite.au3> #include <SQLite.dll.au3> Local $hQuery, $aRow, $sMsg _SQLite_Startup () If @error > 0 Then MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!") Exit - 1 EndIf _SQLite_Open (); Open a :memory: database If @error > 0 Then MsgBox(16, "SQLite Error", "Can't Load Database!") Exit - 1 EndIf _SQLite_Exec(-1, 'PRAGMA encoding = "UTF-8";') ; http://sqlite.org/pragma.html _SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);"); CREATE a Table _SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','Không gì quý hon d?c l?p t? do');"); INSERT Data _SQlite_Query (-1, "SELECT c FROM aTest ORDER BY a;", $hQuery); the query While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK $sMsg &= $aRow[0] WEnd _SQLite_Exec (-1, "DROP TABLE aTest;"); Remove the table MsgBox(0,"SQLite",$sMsg & @crlf & "Không gì quý hon d?c l?p t? do") _SQLite_Close () _SQLite_Shutdown () Edited December 5, 2008 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
hoangthi Posted December 8, 2008 Author Share Posted December 8, 2008 data to save not equal data to display. I can't not use UTF-8 in my code please help me !! Link to comment Share on other sites More sharing options...
ProgAndy Posted December 8, 2008 Share Posted December 8, 2008 the problem are the AutoIt-Strings. They use ANSI / Unicode as default and if you want to send strings as UTF-8 you have to encode them first: Global Const $SF_UTF8 = 4 Global Const $SF_ANSI = 1 $data = BinaryToString(StringToBinary("Không gì quý hơn độc lập tự do",$SF_UTF8),$SF_ANSI) ; Make ANSI-stringrepresentation out of UTF-8 $sMsg = BinaryToString(StringToBinary($sMsg,$SF_ANSI),$SF_UTF8) , convert ANSI-UTF8 representation to ANSI/Unicode *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes 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