Thursday 15 May 2014

ios - Iterating through const unsigned char * containing "Extended ASCII" characters -


In the my SQL database for an iPhone app, I have an integer number (up to 5 digits) in a long array of 2 characters To move the string using expanded ASCII character set. (In other words, I encode it using Base 150)

When exiting the database, sqlite3_column_text () returns the string as "const unsigned character *" I printf I can print this string correctly (it correctly displays more than 128 ASCII characters), but when I try to do it again and each string of the string is separated by itsTrying to convert the integer, the ASCII values ​​on 128 fail, because they are multibyte and it is only getting a byte (I think)

example:

I call this string an encoded string in which: svà ??)

  unsigned char c = encoded string [0]; Unsigned char d = encoded string [2]; Printf ("% c", c); // Output "s" printf ("% c", d); // Output "\ 303" printf ("% s", encoded string); // output "svà ??)"   

I have also tried wchar_t with the same result I have worked to use NSStrings, but it is very slow, and I am doing it several thousand times (according to NSMKranger Profiler, the culprit is), so I can get it as fast as possible, so c.

What's the trick to get a single multibyte / expanded ASCII character out of a string? Instead of using a TEXT column, I type a BLOB column itemprop = "text">

I recommend using whatever size in the data you want to use (probably 16-bit unsigned)

You can use sqlite_column_bytes () to define the size of the column, so that they can allow the use of variable-length columns.

It will avoid the complexity you are currently facing.

No comments:

Post a Comment