Re: String Encoding

2012-06-12 Thread Aki Inoue
;>> Aki >>> >>> On 2012/06/12, at 12:42, koko wrote: >>> >>>> I have international users who may have things like umlaut in file names / >>>> paths which I may get as CStrings given our Model. >>>> >>>> What NS st

Re: String Encoding

2012-06-12 Thread koko
esentationWithPath:] and >> -[NSFileManager stringWithFileSystemRepresentation:]. >> >> Aki >> >> On 2012/06/12, at 12:42, koko wrote: >> >>> I have international users who may have things like umlaut in file names / >>> paths which I may get a

Re: String Encoding

2012-06-12 Thread Stephane Sudre
ave things like umlaut in file names / >> paths which I may get as CStrings given our Model. >> >> What NS string encoding should be used to preserve the umlaut and not crash? >> Is NSUTF8 OK? >> >> -koko >> >> >> >> >> __

Re: String Encoding

2012-06-12 Thread Aki Inoue
: > I have international users who may have things like umlaut in file names / > paths which I may get as CStrings given our Model. > > What NS string encoding should be used to preserve the umlaut and not crash? > Is NSUTF8

Re: String Encoding

2012-06-12 Thread Wim Lewis
On 12 Jun 2012, at 12:42 PM, koko wrote: > I have international users who may have things like umlaut in file names / > paths which I may get as CStrings given our Model. > > What NS string encoding should be used to preserve the umlaut and not crash? > Is NSUTF8 OK? UTF-8 ca

String Encoding

2012-06-12 Thread koko
I have international users who may have things like umlaut in file names / paths which I may get as CStrings given our Model. What NS string encoding should be used to preserve the umlaut and not crash? Is NSUTF8 OK? -koko ___ Cocoa-dev mailing

Re: How to detect string encoding before reading a file in NSString?

2011-04-27 Thread Laurent Daudelin
Thanks, John. I'll give it a shot! -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/ Logiciels Nemesys Software laur...@nemesys-soft.com On Apr 27, 2011, at 12:35, John Pannell

Re: How to detect string encoding before reading a file in NSString?

2011-04-27 Thread John Pannell
Hi Laurent- Certainly. I've zipped up two classes that wrap some functionality from the Text Conversion Manager functions. I'm certain I got these from somewhere else years ago, but failed to find them now. Download at: http://www.positivespinmedia.com/dev/TEC.zip Usage looks something like

Re: How to detect string encoding before reading a file in NSString?

2011-04-27 Thread Laurent Daudelin
John, Not sure if you read my last email on the topic but using the NSAttributedString initWithURL:encoding:documentAttributes: is failing. I have read a bit about the Text Conversion Manager but if you had already some code you could share, that would spare me reinventing the wheel! Thanks in

Re: How to detect string encoding before reading a file in NSString?

2011-04-27 Thread Laurent Daudelin
On Apr 26, 2011, at 11:43, Nick Zitzmann wrote: > On Apr 26, 2011, at 12:13 PM, Laurent Daudelin wrote: > >> I've found different ways to do that (some pure Cocoa, some using Carbon) >> but I was wondering about the wisdom of this list as to what is the best way >> to detect the encoding of a f

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Laurent Daudelin
Thanks, John. I'll have a look and let you know if I need more help! -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/ Logiciels Nemesys Software laur...@nemesys-soft.com On Apr 26, 20

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Greg Guerin
Laurent Daudelin wrote: I've found different ways to do that (some pure Cocoa, some using Carbon) but I was wondering about the wisdom of this list as to what is the best way to detect the encoding of a file before passing it to NSString initWithContentsOfFile:encoding:error:? You might

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Andrew Thompson
Another battle tested piece of code would be Mozilla's sniffer, if external libraries and it's license suit you. This document is out of date, bur explains the ideas. http://www.mozilla.org/projects/intl/detectorsrc.html On Apr 26, 2011, at 3:39 PM, John Pannell wrote: > Hi Laurent- > >

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread John Pannell
Hi Laurent- I have an app that collects a lot of text off the web; my string creation algorithm is something like the following: 1. Attempt to create an NSString with NSUTF8StringEncoding. 2. If the string is nil, attempt to create the string using the encoding returned from the server. 3. I

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Nick Zitzmann
On Apr 26, 2011, at 12:49 PM, Laurent Daudelin wrote: >> TextEdit's encoding guesser just uses the built-in NSAttributedString method >> -initWithURL:options:documentAttributes:error:, which will guess the file's >> encoding when opening it. But it has been mentioned that heuristics are not >>

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Laurent Daudelin
On Apr 26, 2011, at 11:43, Nick Zitzmann wrote: > On Apr 26, 2011, at 12:13 PM, Laurent Daudelin wrote: > >> I've found different ways to do that (some pure Cocoa, some using Carbon) >> but I was wondering about the wisdom of this list as to what is the best way >> to detect the encoding of a f

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Nick Zitzmann
On Apr 26, 2011, at 12:13 PM, Laurent Daudelin wrote: > I've found different ways to do that (some pure Cocoa, some using Carbon) but > I was wondering about the wisdom of this list as to what is the best way to > detect the encoding of a file before passing it to NSString > initWithContentsOf

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Heath Borders
Obviously, there are sometimes overlaps between encodings when you're trying to guess. http://en.wikipedia.org/wiki/Bush_hid_the_facts -Heath Borders heath.bord...@gmail.com Twitter: heathborders http://heath-tech.blogspot.com On Tue, Apr 26, 2011 at 1:18 PM, Dave DeLong wrote: > You'd have t

Re: How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Dave DeLong
You'd have to guess (by reading the first few bytes of the file, seeing what they are and how they're laid out, etc), or use the initWithContentsOfFile:usedEncoding:error: variant to let NSString guess for you. Dave On Apr 26, 2011, at 11:13 AM, Laurent Daudelin wrote: > I've found different

How to detect string encoding before reading a file in NSString?

2011-04-26 Thread Laurent Daudelin
I've found different ways to do that (some pure Cocoa, some using Carbon) but I was wondering about the wisdom of this list as to what is the best way to detect the encoding of a file before passing it to NSString initWithContentsOfFile:encoding:error:? -Laurent. -- Laurent Daudelin AIM/iChat/

Re: NSPropertyListSerialization and string encoding

2010-07-23 Thread Joe Turner
Hey, Thanks! It seems that all I had to do sanitize was encode &'s <'s >'s "'s and ''s, and then just do my normal percent encoding, and everything is now working great! Thanks! Joe On Jul 23, 2010, at 2:11 PM, Kyle Sluder wrote: > On Fri, Jul 23, 2010 at 11:54 AM, Joe Turner wrote: >> Howev

Re: NSPropertyListSerialization and string encoding

2010-07-23 Thread Kyle Sluder
On Fri, Jul 23, 2010 at 11:54 AM, Joe Turner wrote: > However, now it seems my issue is with &'s in the data itself from the > property list. If the plist contained an "&" somewhere, everything after that > point is cut off (which makes sense). Is there any way around this? It seems > I have to

Re: NSPropertyListSerialization and string encoding

2010-07-23 Thread Joe Turner
However, now it seems my issue is with &'s in the data itself from the property list. If the plist contained an "&" somewhere, everything after that point is cut off (which makes sense). Is there any way around this? It seems I have to percent escape the data before posting, which (the only way

Re: NSPropertyListSerialization and string encoding

2010-07-23 Thread Kyle Sluder
On Fri, Jul 23, 2010 at 9:34 AM, Joe Turner wrote: > Hey, > > No one is requiring me to send a string–I do indeed send it as data, but I > must convert values from string to data. Like, I have a title field, in which > I must convert the title to NSData. But since there are a bunch of arguments

Re: NSPropertyListSerialization and string encoding

2010-07-23 Thread Joe Turner
Hey, No one is requiring me to send a string–I do indeed send it as data, but I must convert values from string to data. Like, I have a title field, in which I must convert the title to NSData. But since there are a bunch of arguments like this, I just make a string like @"arg1=something&arg2=s

Re: NSPropertyListSerialization and string encoding

2010-07-22 Thread Kyle Sluder
On Thu, Jul 22, 2010 at 6:25 PM, Joe Turner wrote: > I'm having an issue with NSPropertyListSerialization, where I will call > dataWithPropertyList:format:options:error:, to get the data from a property > list–this part goes fine. However, then I need the data as a string, so I can > upload it

Re: NSPropertyListSerialization and string encoding

2010-07-22 Thread James Walker
On 7/22/2010 6:25 PM, Joe Turner wrote: I'm having an issue with NSPropertyListSerialization, where I will call dataWithPropertyList:format:options:error:, to get the data from a property list–this part goes fine. However, then I need the data as a string, so I can upload it to a web service. Ho

NSPropertyListSerialization and string encoding

2010-07-22 Thread Joe Turner
Hello, I'm having an issue with NSPropertyListSerialization, where I will call dataWithPropertyList:format:options:error:, to get the data from a property list–this part goes fine. However, then I need the data as a string, so I can upload it to a web service. However, when I call initWithData:

Re: String Encoding problem with Unicode

2008-07-10 Thread Alastair Houghton
AAARGH! This is a Cocoa question (and I thought I was replying to the Cocoa list too). Sandeep, please don't BCC mailing lists, and please post questions in *one* place---even if you're not sure, someone will tell you where to ask if it isn't right. (And apologies to the ObjC list for c

String Encoding problem with Unicode

2008-07-10 Thread Sandeep Nair
Sir, i want to convert a NSString to CString using Unicode Encoding. strcpy(cString, [nsString cStringUsingEncoding:NSUnicodeStringEncoding ]); (or) CFStringGetCString((CFStringRef)nsString], cString,1024, CFStringConvertNSStringEncodingToEncoding(NSUnicodeStringEncoding)); Here i am co