SQLite Support for Chinese paths (used by Stringtowidechar and Utf8encode in the D7 system unit)

Source: Internet
Author: User
Tags sqlite

The recent use of SQLite as a database, found that if the direct delivery of a database with Chinese path or file name, will cause the database can not open the situation.
Looked at the source of SQLite, only to find that the original SQLite is used UTF8 encoding file open operation.

So, when you pass a file name, you need to encode it. In Delphi, use the following function.

function Translatedbfile (str:string): string;
Var
tmp:utf8string;
L:integer;
L_widestring:pwidechar;
L_length:integer;
Begin
If Isenglishstring (STR) Then
Result: = Str
Else
Begin
L_length: = Length (STR) * 2;
Getmem (l_widestring, l_length);

Stringtowidechar (Str, l_widestring, l_length);

Result: = Utf8encode (STR);
Getmem (l_widestring, 0);

End
End

The Stringtowidechar and Utf8encode are included in the D7 system unit. Simple and convenient.

Http://www.cnblogs.com/qiubole/archive/2007/11/07/951807.html

SQLite Support for Chinese paths (used by Stringtowidechar and Utf8encode in the D7 system unit)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.