Results 1 to 4 of 4

Thread: SQLite encoding problem

  1. #1
    Join Date
    Oct 2008
    Location
    Germany
    Posts
    29
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default SQLite encoding problem

    Hi everyone,

    I have a problem with selecting German umlauts (ä ö ü) from an SQLite-Database.

    There is one thing that works an another that doesn't.

    Here the working example:

    Qt Code:
    1. QSqlQuery query;
    2. query.prepare("SELECT name, surname FROM names WHERE nameid=?");
    3. ...
    To copy to clipboard, switch view to plain text mode 

    This return for example "Max" and "Müller".

    BUT if I want to select it in one combined string like this it returns some strange characters.

    Qt Code:
    1. QSqlQuery query;
    2. query.prepare("SELECT name || ' ' || surname FROM names WHERE nameid=?");
    3. ...
    To copy to clipboard, switch view to plain text mode 

    In my case this returns "Max M?ller". It's the same dataset just a differen SELECT. What am I doing wrong?

    Thanks in advance
    Chris

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: SQLite encoding problem

    Hi, may it could help if you execute following
    Qt Code:
    1. PRAGMA encoding = "UTF-8";
    To copy to clipboard, switch view to plain text mode 
    and did
    Qt Code:
    1. SELECT name || surname FROM names WHERE nameid=?
    To copy to clipboard, switch view to plain text mode 
    also return a corrupt umlaut?

    EDIT: what encoding has your cpp file?
    Last edited by Lykurg; 27th September 2009 at 09:25.

  3. #3
    Join Date
    Oct 2008
    Location
    Germany
    Posts
    29
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: SQLite encoding problem

    Hi,

    the first solution didn't work.

    I think all the cpps are encoded using latin1.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: SQLite encoding problem

    and if you skip the blank in you "concat"? Is the umlaut then also corrupted? Seems to be a problem between your latin1-string and the internal utf8 of sqlite.

Similar Threads

  1. Problem regarding SQLITE commands
    By sudheer168 in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2008, 08:09
  2. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  3. deployment problem: msvc++ 2008 Express, Qt 4.4.3
    By vonCZ in forum Qt Programming
    Replies: 7
    Last Post: 10th November 2008, 14:38
  4. Problem in using QHttp with QTimer
    By Ferdous in forum Newbie
    Replies: 2
    Last Post: 6th September 2008, 12:48
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.