Difference between revisions of "SHIP:Data Types:String"

From Serious Documentation
Jump to: navigation, search
({{DataType|String}})
Line 14: Line 14:
  
 
{{DataType|String}} constants are written in [[SHIP:Sail|Sail Scripts]] enclosed in double quotes (&quot;), and can be concatenated using the <code>+</code> operator.
 
{{DataType|String}} constants are written in [[SHIP:Sail|Sail Scripts]] enclosed in double quotes (&quot;), and can be concatenated using the <code>+</code> operator.
 
  
 
{{DataType|String}} constants with alternate language translations can be created using {{Node|string|string}} and {{Node|text|text}} nodes in the {{Node|resources|resources}} area.  
 
{{DataType|String}} constants with alternate language translations can be created using {{Node|string|string}} and {{Node|text|text}} nodes in the {{Node|resources|resources}} area.  

Revision as of 05:16, 19 April 2014

See Also

String

Stings in SHIP are a sequence of UTF8 characters terminated in an implicit end-of-string character.

Data Type Description
String A sequence of UTF8 characters terminated in an implicit end-of-string character.

String constants are written in Sail Scripts enclosed in double quotes ("), and can be concatenated using the + operator.

String constants with alternate language translations can be created using string and text nodes in the resources area.

Sail String Functions enable you to access the Unicode codepoints within a String, count the character length of the String, access subsets of the String, and more.

Examples

This is an example of assigning a String constant to a text node within a Sail script:

 text.value = "hello";

And this example shows string concatenation:

 text.value = "hello" + " " + "there";

You can define strings with alternate language translations using string and text nodes. These translated string resources can be combined at runtime in Sail scripts to form larger strings, for example if you have a string resource:

tWelcome
  enUS: Welcome
  frFR: Bienvenue

a Sail script can combine these using simple concatenation:

text.value = tWelcome + " Terry";