• 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: [Solved] Re: Storing UTF8 Umlauts in Postgres using PGSQLKit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Solved] Re: Storing UTF8 Umlauts in Postgres using PGSQLKit


  • Subject: Re: [Solved] Re: Storing UTF8 Umlauts in Postgres using PGSQLKit
  • From: Alexander Reichstadt <email@hidden>
  • Date: Thu, 22 Mar 2012 14:28:06 +0100

Hi, sorry to hear that, but great to meet you here!! Let's catch up off list.

Alex




Am 22.03.2012 um 14:20 schrieb Andy 'Dru' Satori:

> Sorry I didn't see this, I was KO'd by the pollen and seasonal allergies.   Yes this is an issue with PGSQLkit, I have confirmed it and will be committing a change today based upon yours to address this.  Thanks for patch!
>
> --
> Andy 'Dru' Satori
>
> On Thursday, March 22, 2012 at 6:55 AM, Alexander Reichstadt wrote:
>
>> The issue was in PGSQLKit.
>>
>> -(NSString *)sqlEncodeString:(NSString *)toEncode
>> {
>>
>> //size_t result;
>> int	error;
>> char *sqlEncodeCharArray = malloc(1 + ([toEncode length] * 2)); // per the libpq doc.
>> const char *sqlCharArrayToEncode = [toEncode cStringUsingEncoding:defaultEncoding];
>> size_t length = strlen(sqlCharArrayToEncode);
>> PQescapeStringConn ((PGconn *)pgconn, sqlEncodeCharArray,
>> (const char *)[toEncode cStringUsingEncoding:defaultEncoding],
>> length, &error);
>> //This is bad
>> //	NSString *encodedString = [[[NSString alloc] initWithFormat:@"%s",sqlEncodeCharArray] //autorelease];
>> //Instead use
>> NSString *encodedString = [NSString stringWithCString:sqlEncodeCharArray encoding:defaultEncoding];
>>
>> free(sqlEncodeCharArray);
>> return encodedString;
>> }
>>
>>
>>
>>
>> Am 22.03.2012 um 09:09 schrieb Alexander Reichstadt:
>>
>>> Hi,
>>>
>>>
>>> for a couple of reasons we migrated our project from mysql to postgres using PGSQLKit.
>>>
>>> But we are experiencing problems storing UTF8 data. So far we checked the database to be able to store UTF8. When using pgPHPAdmin to store values with German Umlaute it works. When using PGSQLKit chars get garbled.
>>>
>>> The following code stores the values:
>>>
>>>
>>> const char *cString = [sql cStringUsingEncoding:NSUTF8StringEncoding];
>>> if (cString == NULL)
>>> {
>>> self.errorDescription = [NSString stringWithFormat:@"ERROR: execCommand could not be losslessly converted to c string: %@", sql];
>>> [self appendSQLLog:[NSString stringWithFormat:@"%@\n", self.errorDescription]];
>>> return NO;
>>> }
>>> res = PQexec(pgconn, cString);
>>>
>>> Both sides seem correct, server as well as client, so I am not sure what the issue might be.
>>>
>>> Any ideas?
>>>
>>> Thanks
>>> Alex
>>> _______________________________________________
>>>
>>> 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
>>
>> _______________________________________________
>>
>> 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
>

_______________________________________________

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: 
 >Storing UTF8 Umlauts in Postgres using PGSQLKit (From: Alexander Reichstadt <email@hidden>)
 >[Solved] Re: Storing UTF8 Umlauts in Postgres using PGSQLKit (From: Alexander Reichstadt <email@hidden>)
 >Re: [Solved] Re: Storing UTF8 Umlauts in Postgres using PGSQLKit (From: "Andy 'Dru' Satori" <email@hidden>)

  • Prev by Date: Re: [Solved] Re: Storing UTF8 Umlauts in Postgres using PGSQLKit
  • Next by Date: advice for creating these controls
  • Previous by thread: Re: [Solved] Re: Storing UTF8 Umlauts in Postgres using PGSQLKit
  • Next by thread: CALayer composition changes with frame position
  • Index(es):
    • Date
    • Thread