Sign in to follow this  
Followers 0
javalover

sqlite utf8 problem on exec

1 post in this topic

Utf-8 char error on sqlite.

CODE
Func InitTables()

$file = FileOpen($BASE_DIR & "records.txt",0)

; Check if file opened for reading OK

If $file = -1 Then

Exit

EndIf

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

$cmd = $line

If Not _SQLite_Exec (-1, $cmd ) = $SQLITE_OK Then

MsgBox(16, "SQLite Error", _SQLite_ErrMsg () & " On Cmd:" & $cmd )

Else

Call("GUIConsoleWrite","Success exec Cmd: " & $cmd & @CRLF)

EndIf

WEnd

Call("CheckDB")

EndFunc

Func CheckDB()

$d = _SQLite_Exec(-1,"Select oid,* From Info","_cb") ; _cb Will be called for each row

EndFunc

Func _cb($aRow)

For $s In $aRow

Call("GUIConsoleWrite",$s & @TAB)

Next

Call("GUIConsoleWrite",@CRLF)

EndFunc

File records.txt (edited in utf-8)

CODE
DROP TABLE Info;

CREATE TABLE Info (Type, Name);

INSERT INTO Info (Type, Name) VALUES ('bank','UOB ธน好าค');

Run function 'InitTables'

GUI Edit displays the following:

CODE
Success exec Cmd: DROP TABLE Info;

Success exec Cmd: CREATE TABLE Info (Type, Name);

Success exec Cmd: INSERT INTO Info (Type, Name) VALUES ('bank','UOB ธน好าค');

rowid Type Name

1 bank UOB ??好??

The problem is 'ธน好าค' changed to '??好??' , why utf-8 chinese '好' is correct , but the other country utf-8 char is wrong

OS:windows XP

Language: Simple-chinese

AutoIt3 : SciTE4AutoIt3 Version 1.71 Nov 25 2007 09:22:42

Share this post


Link to post
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
Sign in to follow this  
Followers 0