4 ms·
.NET uses 16-bit characters, but you can use the System.Globalization.StringInfo class to iterate through a string one Unicode character at a time, index into s
by kvb 13y ago
.NET uses 16-bit characters, but you can use the System.Globalization.StringInfo class to iterate through a string one Unicode character at a time, index into strings by Unicode character, etc. The API's a bit awkward, but it works.
- panzi 13y agoOne unicode character at a time or one unicode codepoint at a time? (see character composition)
- kvb 13y agoGood point - I meant one codepoint at a time.
- kvb 13y agoBut I was wrong and it's actually by grapheme, as danbruc correctly notes.
- masklinn 13y agoCodepoint. Java 5 also added new string APIs for this. IIRC, Cocoa is one of the very few frameworks/languages/whatever which provides APIs for manipulating and iterating on grapheme clusters out of the box. And provides a page explaining some of the unicode concepts and how they map to NSString: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Strings/Articles/stringsClusters.html#//apple_ref/doc/uid/TP40008025 https://developer.apple.com/library/mac/documentation/Cocoa/...
- danbruc 13y agoThe .NET StringInfo class provides methods to work at the grapheme level, not code points.