Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

Offset vs Range methods

Method

rangeOfCharacterAt: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. Gets the string range from a character index.

Signature

+ (NSRange)rangeOfCharacterAt:(NSNumber *)offset inString:(NSString *)aString

Parameters

offset = AppleScript character index

aString = a string

Result

A range record

Availability

Version 1.0.0

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 rangeOfCharacterAt:3 inString:aString

--> {location:2, length:2}

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

--> {location:4, length:1}


Click here to open script in a script editor