You are not logged in.

#1 2009-10-02 14:15:41

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

utf8 and utf16 strings, C++

I am working on a project and I'd like to use sqlite3 to store permanent data.
The C API comes in two flavours: strings encoded in utf8 and strings encoded in utf16.

So my questions are: how can I know how the non ASCII character are sent to my program?

I can be sure that if the current locale LC_CTYPE is named .*\.utf8 then the strings will be utf8 encoded?

And if the current locale it is not .*\.utf8, how can I know the locales installed and so set it?

I read something about in the internet, but I could find nothing about the point 2 and 3... Thanks for any insight.
etb

Offline

#2 2009-10-02 16:30:02

gnud
Member
Registered: 2005-11-27
Posts: 182

Re: utf8 and utf16 strings, C++

Well -- the answers depend on facts you didn't provide.

If your locale is *.UTF-8, then all text from a terminal will be in utf-8, but you can still have a file in, say, iso-8859-1. When you read this file, it won't get converted to utf8. You'll have to manage conversions yourself.

Offline

#3 2009-10-02 19:50:34

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: utf8 and utf16 strings, C++

Oh yes, sorry. I meant text from the terminal. Like arguments.

Offline

Board footer

Powered by FluxBB