Jump to content

Please help me!


 Share

Recommended Posts

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

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 by KaFu
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...