title: Single quote encoding issue reading from sqlite for iPhone
body: <p>I have created an SQLite db for iPhone to store my data (strings).
  I have some data that contains ' single quotes (i.e. don't be tense).
  This was inserted into the DB using the normal '' escape for SQLite.</p>
  
  <p><code>
  INSERT INTO todo(test) VALUES('don''t be tense');
  </code></p>
  
  <p>When I do a select on the data in Terminal I can see the single quote in the record.</p>
  
  <p><code>
  don't be tense
  </code></p>
  
  <p>My problem is when I read the record in, the single quote is not there in the NSLog:</p>
  
  <p><code>
  dont be tense
  </code></p>
  
  <p>This is the call to read in the field:</p>
  
  <p><code>
  self.text = [NSString stringWIthUTF8String:(char *)sqlite3_column_text(init_statement, 1)];
  NSLog(@"%@",self.translation);
  </code></p>
  
  <p>I would greatly appreciate help on how to ensure the quote is read in.</p>
  
  <p>Below is the full code, if it helps:</p>
  
  <pre><code>static sqlite3_stmt *init_statement = nil;
  
  @implementation Todo
  @synthesize primaryKey,text;
  
  - (id)initWithPrimaryKey:(NSInteger)pk database:(sqlite3 *)db {
  
      if (self = [super init]) {
          primaryKey = pk;
          database = db;
          // Compile the query for retrieving book data. See insertNewBookIntoDatabase: for more detail.
          if (init_statement == nil) {
              // Note the '?' at the end of the query. This is a parameter which can be replaced by a bound variable.
              // This is a great way to optimize because frequently used queries can be compiled once, then with each
              // use new variable values can be bound to placeholders.
              const char *sql = "SELECT text FROM todo WHERE pk=?";
              if (sqlite3_prepare_v2(database, sql, -1, &amp;init_statement, NULL) != SQLITE_OK) {
                  NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
              }
          }
          // For this query, we bind the primary key to the first (and only) placeholder in the statement.
          // Note that the parameters are numbered from 1, not from 0.
          sqlite3_bind_int(init_statement, 1, primaryKey);
          if (sqlite3_step(init_statement) == SQLITE_ROW) {
              self.text = [NSString stringWithUTF8String:(char *)sqlite3_column_text(init_statement, 0)];
            NSLog(@"%@",self.text);
          } else {
              self.text = @"Nothing";
          }
          // Reset the statement for future reuse.
          sqlite3_reset(init_statement);
      }
      return self;
  }
  </code></pre>