Class: String
Description
This method returns a substring of the String instance, starting at first, and containing as many characters that fits in maxBytes bytes, using the current character set representation.
Syntax
StringObject.byteLimitSubstring(Number first, Number maxBytes)
Parameters
first |
Starting position of the substring. If the value is less than 1, returns 1. |
maxBytes |
The maximum number of bytes that shall be occupied by the substring |
Returns
The String BLS = StringObject.extract( first, N) with N such that all of the following conditions are met:
N >= first and N <= max( StringObject.length(), first)
BLS.toByteString().length() <= maxBytes
Either N >= StringObject.length() OR StringObject.extract( first, N+1).toByteString().length() > maxBytes
When Became Available
Profile V7.0
Example
type String STR = "Knäckebröd"
type String BLS1 = STR.byteLimitSubstring( 1, 3) // "Kn"
type String BLS2 = STR.byteLimitSubstring( 2, 5) // "näck"
type String BLS1 = STR.byteLimitSubstring( 3, 8) // "äckebr"
type String BLS1 = STR.byteLimitSubstring( 3, 9) // "äckebrö"