Re: Public API method naming for NSString * / const char * parameters
Re: Public API method naming for NSString * / const char * parameters
- Subject: Re: Public API method naming for NSString * / const char * parameters
- From: "email@hidden" <email@hidden>
- Date: Mon, 03 Mar 2014 16:09:44 +0000
On 3 Mar 2014, at 15:19, Daniel DeCovnick <email@hidden> wrote:
> But, assuming for the moment that you have a really good reason for such a Cocoa-unfriendly API:
>
> “UTF8Name" is highly specific. I’d first consider what your source encoding is (both of the strings that are likely to be passed to this method and of whatever data it’s searching). Do these class names ever even have characters from outside the ASCII character set or could they in the future?
Hmm.That’s a good point. I was hung up on the Cocoa side of things.
Commonly the char *strings represent a C# identifier http://msdn.microsoft.com/en-us/library/aa664670.aspx
The rules for identifiers given in this section correspond exactly to those recommended by the Unicode Standard Annex 15. http://unicode.org/reports/tr15/
In actual fact though the identifier may represent an identifier from any CLR language.
The char * is derived from XML that is sourced from reflecting on a .NET binary assembly
This assembly may, in theory at least, have been written in any supported CLR language (though I have severe doubts about whether this would occur in practice).
Hence the Common Language Specification could then apply: http://msdn.microsoft.com/en-us/library/12a7a7h3(v=vs.110).aspx
This is governed by the CLS specification, chapter 8.5.1 "Valid names":
CLS Rule 4: Assemblies shall follow Annex 7 of Technical Report 15 of the Unicode Standard 3.0 governing the set of characters permitted to start and be included in identifiers, available on-line athttp://www.unicode.org/unicode/reports/tr15/tr15-18.html. Identifiers shall be in the canonical format defined by Unicode Normalization Form C. For CLS purposes, two identifiers are the same if their lowercase mappings (as specified by the Unicode locale-insensitive, one-to-one lowercase mappings) are the same. That is, for two identifiers to be considered different under the CLS they shall differ in more than simply their case. However, in order to override an inherited definition the CLI requires the precise encoding of the original declaration be used.
Unicode is not a subject about which I know much so much of the above is pretty opaque.
However, UTF8 is obviously not a good choice of prefix.
Perhaps Unicode or CLR/CLS would be more precise.
J
_______________________________________________
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