Binary strings: Difference between revisions

m
Line 1,530:
Pascal strings are an array of bytes with the string length stored in byte 0.
CFStrings are immutable objects that encode a Unicode-compliant text string, represented as a sequence of UTF–16 code units. All lengths, character indexes, and ranges are expressed in terms of 16-bit platform-endian values, with index values starting at 0. The private contents of the string object are accessed via a pointer to its address. CFStrings are technically unlimited in length. While basic CFString manipulation is shown below, FB's CocoaUI offers a host of sophisticated accessor functions. Immutable CFStrings have a mutable sister, CFMutableStrings.
 
<syntaxhighlight lang="futurebasic"
'''Pascal String Examplesexample:'''
<syntaxhighlight lang="futurebasic">
// Pascal Strings (limited to 255 characters)
print "----------------------"
Line 1,567 ⟶ 1,569:
a = "Hello, world!"
for i = 1 to len$(a)
if ( mid$( a, i, 5 ) == "world" )
a = left$( a, i -1 ) + "universe" + mid$( a, i + 5 )
end if
next
print a
Line 1,578 ⟶ 1,580:
print : print
 
HandleEvents
// CFStrings (tecnhically unlimited length)
</syntaxhighlight>
// Pascal Strings (limited to 255 characters)
{{output}}
<pre>
----------------------
Pascal String Examples
----------------------
Length of "Hello, world!" is 13 characters.
String is empty
Hello, universe!
See you later.
</pre>
 
'''CFSString example:'''
<syntaxhighlight lang="futurebasic">
print @"----------------------"
print @" CFString Examples"
Line 1,610 ⟶ 1,625:
 
// Extract a substring
b = mid( c, 1, 5 ) // bytes 1 -> 5
 
// Substitute string "world" with "universe"
Line 1,630 ⟶ 1,645:
{{output}}
<pre>
----------------------
Pascal String Examples
----------------------
Length of "Hello, world!" is 13 characters.
String is empty
Hello, universe!
See you later.
 
 
----------------------
CFString Examples
717

edits