The problem and solution about Sqlite3 Chinese garbled in Linux system

Source: Internet
Author: User
Tags sqlite
A new project is not a problem in the local (WIN8) test, but the data that is queried from the Sqlite3 database when it is uploaded to the server (Linux) is garbled (normal in the database), and the PHP files and HTML files are set to unified UTF8 or the same. There is no use in finding solutions on the Web. WORKAROUND: Re-process the queried data and cast all to UTF8
Open db.db Table $db = new SQLite3 (' db.db '), if (! $db) {   echo $db->lasterrormsg ();   Exit;} else {} $keys = array (), $students = Array (),//Query $ret = $db->query ("SELECT * FROM Student limit 50"),//Save the result to the new array while ($ro W = $ret->fetcharray (SQLITE3_ASSOC)) {   $keys = Array_keys ($row);   Convert column values to prevent garbled   foreach ($keys as $key) {      $row [$key] = mb_convert_encoding ($row [$key], "gb2312", "Utf-8");   }   Add to new array   Array_push ($students, $row);} $db->close ();p rint_r ($students);

  

Reference: Sqlite#pragma_encoding A summary of the SQLite version and Chinese garbled set pragma encoding = "UTF-16" for main database in SQLite



From for notes (Wiz)



The problem and solution about Sqlite3 Chinese garbled in Linux system

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.