[odb-users] supporting Chinese?

Boris Kolpackov boris at codesynthesis.com
Mon Aug 27 08:01:30 EDT 2012


In the future please keep your replies CC'ed to the odb-users mailing
list as discussed in the posting guidelines:


yb947835908 at gmail.com writes:

> Hi,Boris! I'm using Sqlite.As you may know, it's not difficult to write
> some codes to make some conversions so that we could use Chinese words on
> the Sqlite database. But I don't think those codes works on ODB because of
> the generating-code thing. Actaully, I'm totally lost,I don't even know
> where to start with, to write the conversion-codes. So, have you got any
> ideas?

The SQLite C API allows one to execute Unicode statements as long as
they are encoded in UTF-8. This means that you can use Unicode table
and column names as long as you specify them in UTF-8. I modified the
'hello' example to use letter 'é' (e with acute, UTF-8 2-byte encoding
is 0xC3, 0x88) in both table and column names:

#pragma db object table("p\xC3\x88rson")
class person

  #pragma db column("ag\xC3\x88")
  unsigned short age_;

Everything seems to work fine. So if you want to use Chinese in your
table/column names with SQLite, then you will need to get their UTF-8
encodings and specify those in the table/column pragmas.


More information about the odb-users mailing list