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

2012-03-22 Thread 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 (Cocoa-dev@lists.apple.com 
  (mailto:Cocoa-dev@lists.apple.com))
  
  Please do not post admin requests or moderator comments to the list.
  Contact the moderators at cocoa-dev-admins(at)lists.apple.com 
  (http://lists.apple.com)
  
  Help/Unsubscribe/Update your Subscription:
  https://lists.apple.com/mailman/options/cocoa-dev/lxr%40mac.com
  
  This email sent to l...@mac.com (mailto:l...@mac.com)
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com 
 (mailto:Cocoa-dev@lists.apple.com))
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com 
 (http://lists.apple.com)
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dru%40druware.com
 
 This email sent to d...@druware.com (mailto:d...@druware.com) 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Closing an app with the red dot.

2011-05-17 Thread Andy 'Dru' Satori
This is a classic instance of having to look at the nature or the application 
to decide if it is an appropriate action. 

I use both models depending upon the application.  The general approach I take 
is to look at the app in question determine if there is any legitimate reason 
it should stay open when the main window is closed. 

EG. Suppose the application is a simple dialog based app, take for example an 
app I use once or twice a week to decrypt Cisco Group Names from .ini config 
files. Once I've displayed the decrypted password on screen, and closed the 
window, should the app remain loaded? I would argue no. it is small enough that 
reloading it is not an issue, so closing the last window closes the app.

The inverse of this is a document based app. I cannot come up with many reasons 
a document app should ever exit when the last document window is closed. This 
is counter to how Windows devs would function and as many new MAc devs bring 
some of those notions, it is something to be aware of.

In other words, think long and hard before implementing a behavior that is 
non-standard to the platform, or you quickly find yourself in the 'Why am I 
using an app tthe feels like a Windows App on the Mac?' conundrum

-- 
Andy 'Dru' Satori

On Tuesday, May 17, 2011 at 11:40 AM, Uli Kusterer wrote: 
 On 17.05.2011, at 14:54, Andy Lee wrote:
  On May 17, 2011, at 8:44 AM, Andy Lee wrote:
   Also you can implement the 
   applicationShouldHandleReopen:hasVisibleWindows: method mentioned above 
   to automatically reopen the window, if you prefer.
  
  Though I'm not sure as a user I'd like that. Maybe that is what people 
  meant when they said that is the way Mac works.
 
  Doesn't matter what you like as a user, you're a programmer :-p
 
  Seriously, many applications on the Mac work that way. Close all windows in 
 Mail.app and click on the dock: Presto! New mail window.
 
 Cheers,
 -- Uli Kusterer
 The Witnesses of TeachText are everywhere...
 http://www.masters-of-the-void.com
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 http://lists.apple.com/mailman/options/cocoa-dev/dru%40druware.com
 
 This email sent to d...@druware.com
 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com