Text.String

From Fōrmulæ dictionary
Jump to: navigation, search

Text.String the tag for the expression representing a string of text characters.

Definition

This expression must have no children.

This expression has internal state, which is an internal value of the string it contains.

Visualization

There could be different visualizations, according with specific features, such like localization purposes.

Because strings can usually contains spaces, there should be visualizations that show strings indicating where they start and end. Possible methods are:

  • Showing the string as it is
  • Quoting the string
  • Enclosing the string inside a visual artifact, like a rectangle.

Edition

Because this expression has internal state, edition may involve showing a dialog box in order to the user can introduce or edit the actual string.

Reduction

Since this expression is not expected to be reduced to a different one, no reducers are currently known.

Known implementations

The Standard string package

This package provides an implementation of the Text.String expression, which supports the following features:

  • Unicode support. Strings can contain any character in the Unicode standard.

Visualization

There are three visualizations on this package.

Both three visualizations show strings left to right, even in right-to-left written languages.

Simple string visualization

This visualization shows the string as it is, with no additional artifacts. it could be confusing, specially if the string contains spaces. The special case of an empty string, it is shown as the symbol "ε" (without quotes)

Boxed string visualization

This visualization shows strings inside a rectangle, to indicate where the string starts and ends. The following is an example:

String2.png

Quoted string visualization

This visualization shows strings between quotation marks. The symbols of these quotation marks are locale dependent.

Notice that the quotes are visual artifacts added and they are not part of the actual string. If you want to actually add quotes to a given string, use the Localization.QuoteString expression.

The following shows examples of this visualization of an example string, in several locales[1]. This example string is the 7-letter long string Fōrmulæ (æ is a single letter)

Language Example of visualization
Belarussian
Catalan
German (Switzerland)
Greek
Spanish
French
Italian
Norwegian
Portuguese (Portugal)
Russian
Albanian
Ukrainian
«Fōrmulæ»
Bulgarian
Czech
German (Austria, Germany, Greece & Luxembourg)
Estonian
Croatian
Icelandic
Lithuanian
Macedonian
Slovak
Slovenian
Serbian
Hungarian
Polish
„Fōrmulæ”
Finnish
Swedish
”Fōrmulæ”
Arabic ”Fōrmulæ“
Japanese
Chinese (Hong Kong & Taiwan)
「Fōrmulæ」
Hebrew ״Fōrmulæ״
Rest of the world “Fōrmulæ”

Edition

Dialog box where the string is created/edited

When a string expression is created, it substitutes the previous selected expression. After the creation, the new string expression becomes the selected expression.

Edition "Creation of a string"

Since this expression has internal state, it opens a dialog box in order that the user can write the new string. The new Text.String expression substitutes the current selected expression and becomes the new selected expression.

Action "Edition of a string"

Since this expression has internal state, it opens a dialog box in order that the user can edit the string. The internal number of the Text.String currently selected is changed to the new value.

Programming

Internal state

Being an expression with internal state, implementations of this expression must provide the necessary to access this state, and to provide a string representation of this state to be serialized.

Access

Programming language Attribute name Object retrieved
Java "Value" A String object reference containing the string.
C/C++ "Value" A pointer where the string starts.

Serialization

The method of serialization must contain an attribute named "Value" containing the String contained in this Text.String expression.

Examples:

There is no predefined format for expression serialization. The following are examples of Text.String expression in XML format:

String XML format
Fōrmulæ <expression Tag="Text.String" Value="Fōrmulæ"/>
"Free expressions" (quotes included) <expression tag="Text.String" Value="&quot;Free expressions&quot;"/>

References

  1. The list was generated by using the ICU Java library. The quotation definition were requested for all known locale definitions, and grouped. The most numerous group was selected as "The rest of the world".