FROM : Clark Cox
DATE : Wed Dec 22 20:30:43 2004
On Wed, 22 Dec 2004 20:03:20 +0100, Christoffer Lerno <<email_removed>> wrote:
> On Dec 22, 2004, at 17:30, Clark Cox wrote:
>
> > On Wed, 22 Dec 2004 10:56:08 +0100, Christoffer Lerno <<email_removed>>
> > wrote:
> >> Basically I want to know what the heck my file is called after it's
> >> renamed... :) It isn't exactly what I renamed it to, even though it
> >> prints and looks the same.
> >
> > You're forgetting canonical equivalence. Many Unicode characters can
> > be represented multiple ways, but are meant to be considered
> > canonically equivalent. For example, the character "ü" (u with an
> > umlaut, if it gets mangled in transmission) can be represented by
> > either:
>
> I figured that was the problem, but how do I get around this problem?
>
> > A single Unicode codepoint: U+00FC
> > Or two codepoints: U+0075 U+0308
>
> Yes, when I store it, it gets defaulted to whatever scheme the
> filesystem is using. Problem is I still have my NSString in the other
> form... I need to translate this string to the filesystem unicode rep,
> but how? Aside from reading the whole directory and do a compare: and
> retrieve the name by way of searching the whole directory... :-/
I'm just wondering:
If NSFileManager handles the differently normalized strings
appropriately, and -[NSString compare:] also works, then what more do
you need? Basically, my question is: Why do you need to use -isEqual:
instead of -compare:?
If you really need to use isEqual:, then you need to normalize the
strings to the same normalization form (should probably use NFD or
NFC); Like so:
NSString *string1 = ...;
NSString *string2 = ...;
string1 = [string1 decomposedStringWithCanonicalMapping];
string2 = [string2 decomposedStringWithCanonicalMapping];
if([string1 isEqual: string2])
{
...
}
else
{
...
}
--
Clark S. Cox III
<email_removed>
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
DATE : Wed Dec 22 20:30:43 2004
On Wed, 22 Dec 2004 20:03:20 +0100, Christoffer Lerno <<email_removed>> wrote:
> On Dec 22, 2004, at 17:30, Clark Cox wrote:
>
> > On Wed, 22 Dec 2004 10:56:08 +0100, Christoffer Lerno <<email_removed>>
> > wrote:
> >> Basically I want to know what the heck my file is called after it's
> >> renamed... :) It isn't exactly what I renamed it to, even though it
> >> prints and looks the same.
> >
> > You're forgetting canonical equivalence. Many Unicode characters can
> > be represented multiple ways, but are meant to be considered
> > canonically equivalent. For example, the character "ü" (u with an
> > umlaut, if it gets mangled in transmission) can be represented by
> > either:
>
> I figured that was the problem, but how do I get around this problem?
>
> > A single Unicode codepoint: U+00FC
> > Or two codepoints: U+0075 U+0308
>
> Yes, when I store it, it gets defaulted to whatever scheme the
> filesystem is using. Problem is I still have my NSString in the other
> form... I need to translate this string to the filesystem unicode rep,
> but how? Aside from reading the whole directory and do a compare: and
> retrieve the name by way of searching the whole directory... :-/
I'm just wondering:
If NSFileManager handles the differently normalized strings
appropriately, and -[NSString compare:] also works, then what more do
you need? Basically, my question is: Why do you need to use -isEqual:
instead of -compare:?
If you really need to use isEqual:, then you need to normalize the
strings to the same normalization form (should probably use NFD or
NFC); Like so:
NSString *string1 = ...;
NSString *string2 = ...;
string1 = [string1 decomposedStringWithCanonicalMapping];
string2 = [string2 decomposedStringWithCanonicalMapping];
if([string1 isEqual: string2])
{
...
}
else
{
...
}
--
Clark S. Cox III
<email_removed>
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
| Related mails | Author | Date |
|---|---|---|
| Christoffer Lerno | Dec 20, 18:01 | |
| Clark Cox | Dec 20, 20:10 | |
| Jeremy Dronfield | Dec 20, 23:11 | |
| Brendan Younger | Dec 20, 23:29 | |
| Andrew Farmer | Dec 21, 00:04 | |
| Christoffer Lerno | Dec 21, 12:20 | |
| Clark Cox | Dec 21, 15:27 | |
| Christoffer Lerno | Dec 22, 10:41 | |
| Christoffer Lerno | Dec 22, 10:56 | |
| Jeremy Dronfield | Dec 22, 15:03 | |
| Clark Cox | Dec 22, 17:30 | |
| Clark Cox | Dec 22, 17:35 | |
| Jeremy Dronfield | Dec 22, 18:54 | |
| Christoffer Lerno | Dec 22, 20:03 | |
| Christoffer Lerno | Dec 22, 20:10 | |
| Clark Cox | Dec 22, 20:30 | |
| Andreas Mayer | Dec 22, 20:35 | |
| Clark Cox | Dec 22, 21:04 | |
| Christoffer Lerno | Dec 23, 10:53 |






Cocoa mail archive

