SQLite C/C++ API unsigned char *

Why does the SQLite C/C++ API return unsigned char *s for text values as opposed to the more de-facto char * type?

This is somewhat related to the unsigned char question, except that the SQLite API's decision seems opposite of the conventional char * advice given for string-like values.

For example:

const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);

Answers


From the SQLite documentation:

(H13821) The sqlite3_column_text(S,N) interface converts the Nth column in the current row of the result set for the prepared statement S into a zero-terminated UTF-8 string and returns a pointer to that string.

UTF-8 wants byte values ranging from 0x00 to 0xFF. char can range from -0x80 to 0x7F (signed) or 0x00 to 0xFF (unsigned). Forcing unsigned allows the proper encoding of a UTF-8 string.


Need Your Help

Ebean multiple @ManyToMany delivers strange behavior

java playframework playframework-2.0 many-to-many ebean

I experience strange behavior with Ebean (version 3.2.2), whenever I try to use multiple @ManyToMany attributes with CascadeType.ALL in a model.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.