title: Store accented word into Sqlite - iOS
body: <p>I coulnd not find a solution.
  I store data into a local SQLITE DB. Everything works except for accented words.
  As in the figure.</p>
  
  <p><img src="https://i.stack.imgur.com/azRAp.png" alt="enter image description here"></p>
  
  <p>However, if I try to store accented word by using SqliteManager (Firefox plugin) everything works. In conclusion: when I store accented word by using my app, strange chars appear.
  I use the following code to write data (same for read). Basically, all strings are UTF8 encoded.</p>
  
  <pre><code>-(NSInteger)writeData:(NSDictionary* )data table:(NSString* )table
  {
      sqlite3_stmt    *sqlStatement;
      NSMutableArray  *columns   = [[NSMutableArray alloc] init];
      NSMutableArray  *values    = [[NSMutableArray alloc] init];
      NSMutableDictionary *temp = [[NSMutableDictionary alloc] initWithDictionary:data];
      @try {
          assert([data count] != 0);
          if ([[data allKeys] count] == 0) return 1;
  
  
          [temp removeObjectForKey:@"id"];
          [columns addObjectsFromArray:[temp allKeys]];
          NSString        *cols      = [columns componentsJoinedByString:@","];
          NSMutableString *colNames  = [[NSMutableString alloc] initWithString:
                                        [NSString stringWithFormat:@"INSERT INTO %s (",[table UTF8String]]];
  
          [colNames appendString:cols];
          [colNames appendString:@")"];
  
          // VALUES FOR  INSERT
          [values addObjectsFromArray:[temp allValues] ];
          NSMutableString *s = [[NSMutableString alloc] init];
          for(int i = 0; i &lt; [values count]; i++)
          {
              [s setString:[NSString stringWithFormat:@"%@",[values objectAtIndex:i]]];
              const char* currentValue = [s UTF8String];
              [values setObject:[NSString stringWithFormat:@"\"%s\"",currentValue] atIndexedSubscript:i];
          }
          NSString        *vals       = [values componentsJoinedByString:@","];
          NSMutableString *valNames   = [[NSMutableString alloc] initWithString:@" VALUES ("];
          [valNames appendString:vals];
          [valNames appendString:@")"];
  
          [colNames appendString:valNames];
          const char *sql = [colNames UTF8String];
  #ifdef DEBUG
           NSLog(@"avvDB writeDATA insert string %@",colNames);
  #endif
  
          if(sqlite3_prepare(db, sql, -1, &amp;sqlStatement, NULL) != SQLITE_OK)
          {
              NSLog(@"Problem with prepare statement write %s",sqlite3_errmsg(db));
              return 0;
  
          }
          if (sqlite3_exec(db, sql, NULL, NULL, NULL) == SQLITE_OK)
          {
             // NSLog(@"Last id %llu %s",sqlite3_last_insert_rowid(db),sqlite3_errmsg(db));
          }
  
      }// end try
      @catch(NSException* e)
      {
          NSLog(@"Eccezione in write %@",[e reason]);
      }
      @finally {
          sqlite3_reset(sqlStatement);
          sqlite3_finalize(sqlStatement);
          sqlStatement = nil;
          return sqlite3_last_insert_rowid(db);
      }
  
  
  }
  </code></pre>