Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

Offset vs Range methods

Method

locationOfCharacterAt:inString:

Summary

These methods can be used to convert between AppleScript character indexes or offsets (which are based on composed character sequences) and NSRange values (which are based 16-bit unichar values). Range location and character index only differ when the text contains code points ouside Unicode's Basic Multilingual Plane.

Convert a character index from AppleScript to a Cocoa location or NSRange

Signature

+ (NSUInteger)locationOfCharacterAt:(NSNumber *)offset inString:(NSString *)aString

Parameters

offset = AppleScript character index

aString = a string

Result

An integer

Availability

Version 1.1.1

Notes

 

Sample

use scripting additions

use framework "Foundation"

use script "BridgePlus"

load framework


set aString to "A 😀 string."

set theResult to current application's SMSForder's locationOfCharacterAt:3 inString:aString

--> 2

set theResult to current application's SMSForder's locationOfCharacterAt:4 inString:aString

--> 4


Click here to open script in a script editor