Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7072433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:48:30+00:00 2026-05-28T05:48:30+00:00

I have a problem when I add an arabic string to NSMutableArray or NSMutableDictionary

  • 0

I have a problem when I add an arabic string to NSMutableArray or NSMutableDictionary.

Example:

NSMutableDictionary *data = [[NSMutableDictionary alloc]init];
[data setObject:@"فرسان" forKey:@"name"];

NSLog(@"%@",data);

Output:

2012-01-18 21:55:05.646 aa[367:207] {
    name = "\U0641\U0631\U0633\U0627\U0646";
}

my problem exactly i save this data to sqlite [data objectForKey:@”name”] its saved \U0641\U0631\U0633\U0627\U0646 and when fetch data to to put it in UILabel or anything like it the text be \U0641\U0631\U0633\U0627\U0646

Any Help? Thank you 🙂

- (void)SaveMessage {

NSMutableDictionary *TableProperties = [[NSMutableDictionary alloc]init];
[TableProperties setObject:@"INSERT" forKey:@"Operation"];
[TableProperties setObject:@"savedmessages" forKey:@"tableName"];
NSString *string = [[NSString alloc]initWithFormat:@" %@",MessageBox.text];
[TableProperties setValue:string forKey:@"message"];

NSString *msgResult;
NSArray *result = [[DatabaseFunctions database] DataBaseOperation:TableProperties];
if ([[result objectAtIndex:0] isEqualToString:@"Done"]) 
    msgResult = @"تم حفظ الرسالة بنجاح";
else
    msgResult = @"لم تت العملية بنجاح حاول لاحقا";

UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle:@"حفظ الرسالة" 
                      message:msgResult 
                      delegate:self 
                      cancelButtonTitle:@"موافق" 
                      otherButtonTitles:nil, nil ];
[alert show];

}

- (NSArray *)DataBaseOperation:(NSMutableDictionary *)TableProperties{

NSMutableArray *retval = [[NSMutableArray alloc] init];

NSString *Operation = [TableProperties objectForKey:@"Operation"];

if ([Operation isEqualToString:@"SELECT" ]) {

        NSString *tableColumns = [TableProperties objectForKey:@"tableColumns"];
        NSString *tableName    = [TableProperties objectForKey:@"tableName"];
        NSString *tableWhere   = [TableProperties objectForKey:@"tableWhere"];
        NSString *tableOrder   = [TableProperties objectForKey:@"tableOrder"];
        NSString *tableLimit   = [TableProperties objectForKey:@"tableLimit"];

        NSString *Query;
        if ([tableLimit isEqualToString:@"NO"]) {
            Query = [[NSString alloc] initWithFormat:@"SELECT %@ FROM %@ WHERE %@ ORDER BY %@",
                     tableColumns,tableName,tableWhere,tableOrder,tableLimit];
        }else{
            Query = [[NSString alloc] initWithFormat:@"SELECT %@ FROM %@ WHERE %@ ORDER BY %@ LIMIT %@",
                     tableColumns,tableName,tableWhere,tableOrder,tableLimit];
        }

        NSArray *FieldArray = [[TableProperties objectForKey:@"tableColumns"] componentsSeparatedByString:@","];

        sqlite3_stmt *statement;
        if (sqlite3_prepare_v2(_database, [Query UTF8String], -1, &statement, nil) == SQLITE_OK) {
            while (sqlite3_step(statement) == SQLITE_ROW) {

                NSMutableDictionary *Row = [[NSMutableDictionary alloc]init];
                NSString *uniqueId = [[NSString alloc] initWithFormat:@"%i",sqlite3_column_int(statement, 0)];
                [Row setObject:uniqueId forKey:@"uniqueId"];

                for (int i = 1; i<[FieldArray count]; i++) {

                    NSString *column = [[NSString alloc] initWithUTF8String:(char *) sqlite3_column_text(statement, i)];
                    [Row setObject:column forKey:[FieldArray objectAtIndex:i]];

                }
                Objects *rowOfTable = [[Objects alloc] initSelectDataFromTables:Row];                        
                Row = nil;

                [retval addObject:rowOfTable];
            }
            sqlite3_finalize(statement);
        }
}
else if([Operation isEqualToString:@"INSERT" ]) {

    NSString *tableName = [TableProperties objectForKey:@"tableName"];

    [TableProperties removeObjectForKey:@"Operation"];
    [TableProperties removeObjectForKey:@"tableName"];

    NSArray *Columns = [TableProperties allKeys];
    NSArray *Values = [TableProperties allValues];

    NSString *Query = [[NSString alloc] initWithFormat:@"INSERT INTO %@ %@ VALUES %@",tableName,Columns,Values];


    sqlite3_stmt *statement;
    if (sqlite3_prepare_v2(_database, [Query UTF8String], -1, &statement, nil) == SQLITE_OK) 
        if (SQLITE_DONE!=sqlite3_step(statement)){
            NSLog(@"Error when inserting  %s",sqlite3_errmsg(_database));
            [retval addObject:@"Error"];

        }else{
            NSLog(@"Data inserted Successfully");
            [retval addObject:@"Done"];
        }
    else{
        NSLog(@"Error when inserting  %s",sqlite3_errmsg(_database));
        [retval addObject:@"Error"];
    }
    sqlite3_finalize(statement); 
}
return retval;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:48:30+00:00Added an answer on May 28, 2026 at 5:48 am

    When you log an object using %@, NSLog sends the description message to the object and prints the resulting string.

    An NSDictionary responds to the description message by encoding its keys and values in a “safe” format, escaping non-ASCII characters using \U#### codes.

    If you pass the Arabic string to NSLog directly, it will just print the string without the escape codes:

    NSMutableDictionary *data = [[NSMutableDictionary alloc]init];
    [data setObject:@"فرسان" forKey:@"name"];
    
    NSLog(@"data = %@",data);
    NSLog(@"string = %@", [data objectForKey:@"name"]);
    

    Output:

    2012-01-18 14:17:42.498 Animal[62723:f803] {
        name = "\U0641\U0631\U0633\U0627\U0646";
    }
    2012-01-18 14:17:42.500 Animal[62723:f803] فرسان
    

    If you don’t like the way NSDictionary responds to description, you will have to write your own method to format a dictionary as a string and use it to log your dictionary.

    Update

    I have looked at the source code you posted that talks to sqlite. The problem is that you are turning the values array ([TableProperties allValues]) into a string using the %@ format specifier. This sends the description method to the NSArray, which returns a string. Just like NSDictionary, NSArray formats the description string in a “safe” format, escaping non-ASCII characters using \U#### codes.

    You need to write your own method that takes an array and turns it into a string and does not escape special characters. (It needs to escape quotes though.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem to add the dynamic values to a string. For example:
Hi all I have problem with following: foreach (DataRow dr in data.Tables[0].Rows) { string
I have problem with store data in list collection. If I add new data
I have a problem: I've add a Jquery UI drag-n-drop widget to my page,
I have a problem where I have to add thirty-three integer vectors of equal
I have a little problem, I have an array and I want to add
I have to add some enum options to a database table. The problem being,
I have a nHibernate query like this ICriteria query = session.CreateCriteria(typeof(MyResult)) .Add(Expression.Eq(ResultTypeId, myResult.ResultTypeId)) Problem
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have a problem to add a Foreign key to a table. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.