私のiPhoneアプリケーションでは、sqlite dbにアラビア語、グジュラート語を保存して取得したいと考えています。私が読んだそれらのほとんどは、sqlite dbからデータを保存および取得するためにユニコードを使用することです。
How could I accomplish this, could any one instruct me with good tutorial.
前もって感謝します
私のiPhoneアプリケーションでは、sqlite dbにアラビア語、グジュラート語を保存して取得したいと考えています。私が読んだそれらのほとんどは、sqlite dbからデータを保存および取得するためにユニコードを使用することです。
How could I accomplish this, could any one instruct me with good tutorial.
前もって感謝します
Unicode はアラビア語のテキストをサポートしています。sqlite は、UTF-8 エンコーディングを使用して Unicode テキストをサポートします。アラビア語のテキストを NSString に入れることができれば、それを保存して sqlite で取得できます。特別なことをする必要はまったくありません。
// bind a string into a query
NSString *stringWithArabicText = @" some arabic text ";
sqlite3_bind_text(statement, index, [stringWithArabicText UTF8String], -1, SQLITE_TRANSIENT);
// get a string from a query
char *str = (char *)sqlite3_column_text(statement, index);
NSString *stringWithArabicText = [NSString stringWithUTF8String:str];
これは、アラビア語を含む、Unicode でサポートされているすべての言語のテキストで機能します。
SQLite データベースには UTF8 文字セットがあるため、次のようになります。
NSString * stringfromdatabase;
const char *cstring = [stringfromdatabase cStringUsingEncoding:NSISOLatin1StringEncoding];
NSString *utf8string = [[NSString alloc]initWithCString:cstring encoding:NSUTF8StringEncoding];
NSLog(@"%@",utf8string); // here you will see arabic.
もちろん、最適化できます。
このブログをチェックしてください。詳しい解説付きです。
http://programmingiosapps.blogspot.in/2012/08/how-to-save-arab-data-from-iphone-to.html?m=1