• 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: Filename encodings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filename encodings


  • Subject: Re: Filename encodings
  • From: Tito Ciuro <email@hidden>
  • Date: Sat, 10 Jul 2004 23:38:40 -0400

Hello Adam,

If I understand correctly, I believe you should let the OS handle that
by using any of the following methods:

NSString's - (const char *)fileSystemRepresentation
NSFileManager's - (const char
*)fileSystemRepresentationWithPath:(NSString *)path

I hope this helps,

-- Tito

On 10 jul 2004, at 20:49, Adam Maxwell wrote:

> I've written a program to do find and replace on a list of filenames.
> It works quite well, but testing revealed problems with accented
> characters such as i in a filename. I've come up with a workaround,
> but I don't understand why it's necessary, and am curious if I'm
> missing something.
>
> I run an NSOpenPanel, allow multiple file selection, get the selected
> file list as an NSArray, and send it to this method:
>
> - (void)buildPathsArrayWithArray:(NSArray *)array{
> NSEnumerator *e = [array objectEnumerator];
> NSMutableDictionary *dict = [NSMutableDictionary
> dictionaryWithCapacity:2];
> NSString *oldPath = nil;
> NSString *encodedPath = nil;
> NSData *data;
>
> while(oldPath = [e nextObject]){
>
> data = [oldPath dataUsingEncoding:NSMacOSRomanStringEncoding];
> encodedPath = [[[NSString alloc] initWithData:data
> encoding:NSMacOSRomanStringEncoding] autorelease];
> // NSLog(@"encodedPath is %@", encodedPath);
> [dict setObject:encodedPath forKey:@"Old Path"];
> [dict setObject:@"" forKey:@"New Path"];
> ... do more stuff...
> [pathsArray addObject:[dict copy]];
> [dict removeAllObjects];
> }
> }
>
> Unless I use NSMacOSRomanStringEncoding, things don't work right (I'm
> using the AGRegex framework for find/replace). I originally used the
> oldPath variable directly, and for a filename of "iagSGAMMA" (randomly
> chosen), my [pathsArray description] gave
> "e\U0301a\U0301c\U0327SGAMMA". After my NSMacOSRomanStringEncoding
> stuff, the array has "\U00e9\U00e1\U00e7SGAMMA" which actually works.
> Has anyone else run across this, or know of a better way to handle it?
>
> thanks,
> Adam Maxwell
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Filename encodings
      • From: "Mark A. Stratman" <email@hidden>
References: 
 >Filename encodings (From: Adam Maxwell <email@hidden>)

  • Prev by Date: [resend] Questions About Frameworks
  • Next by Date: Re: XCode 1.2 via Software Update?
  • Previous by thread: Filename encodings
  • Next by thread: Re: Filename encodings
  • Index(es):
    • Date
    • Thread