• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: SQLite and Unicode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SQLite and Unicode


  • Subject: Re: SQLite and Unicode
  • From: Michael Ash <email@hidden>
  • Date: Tue, 7 Apr 2009 13:36:57 -0400

2009/4/7 Keary Suska <email@hidden>:
>
> On Apr 7, 2009, at 10:39 AM, Тимофей Даньшин wrote:
>
>>
>> On Apr 7, 2009, at 8:14 PM, Keary Suska wrote:
>>>
>>> Are you properly encoding your C strings with -cStringUsingEncoding:?
>>
>> Yes, I think so.
>> At present, I am using the -UTF8String method, but I also tried the
>> -cStringUsingEncoding: to no avail.
>>
>> Here is the line that binds the string to the prepared statement:
>>        sqlite3_bind_text(sentence_insert_statement, 1, [string
>> UTF8String], -1, SQLITE_TRANSIENT);
>> and I translate it back into NSString by [string stringWithUTF8String],
>> although I also tried the -stringWithCString: encoding: method. The
>> characters _are_ mangled.
>> And the funny thing is that i am able to add non-latin strings to it by
>> reading sql files from SQLite in Terminal...
>
>
> How do you define "string" (i.e. how is its value set)? There can be an
> issue with UTF8 constant strings. Have you called -canBeConvertedToEncoding:
> to make sure "string" is utf-8 compatible?

Note that [string canBeConvertedToEncoding:NSUTF8StringEncoding] will
always return yes, because UTF-8 can represent any unicode string, and
NSString is always* unicode string.

* It is possible to get an NSString which does not contain valid
unicode, by creating an invalid surrogate pair. If you do this,
conversion to UTF-8 will fail, but [string
canBeConvertedToEncoding:NSUTF8StringEncoding] will still return YES!

Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Fwd: SQLite and Unicode (From: Тимофей Даньшин <email@hidden>)
 >Re: SQLite and Unicode (From: Keary Suska <email@hidden>)

  • Prev by Date: Keynote Scripting
  • Next by Date: Check box to indicate more than 2 states
  • Previous by thread: Re: SQLite and Unicode
  • Next by thread: Re: SQLite and Unicode
  • Index(es):
    • Date
    • Thread