Difference between revisions of "Chr"

(Copied user guide content, changed status.)
(examples)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[category:Text Functions]]
 
[[category:Text Functions]]
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
  
= Chr(n) =
+
== Chr(n) ==
  
Returns the character corresponding to the numerical ASCII code ''n'' (a number between 0 and 255). Chr and [[Asc]] are inverses of each other, for example:
+
Returns the character as a text that corresponds to the numerical Unicode value «n» (a number between 0 and 1,114,111=0x10FFFF). [[Chr]] and [[Asc]] are inverses of each other, for example:
:Chr(65) &rarr; ‘A’, [[Asc]](Chr(65)) &rarr; 65
 
:[[Asc]](‘A’) &rarr; 65, Chr([[Asc]](‘A’)) &rarr; ‘A’
 
Chr is useful for creating characters that cannot easily be typed, such as tab, which is Chr(9) and carriage return (CR), which is Chr(13). For example, if you [[ReadTextFile|read in a text file]], x, you can use [[SplitText]](x, Chr(13)) to generate an array of lines from the text.
 
  
= Note =
+
:<code>Chr(65) &rarr; ‘A’</code>
 +
:<code>Asc('A') &rarr; 65</code>
  
The mapping for characters from 128 to 255 is subject to your system's language/region-specific character map.  Analytica 4.0 has adopted a Windows mapping, while Analytica 3.1 and earlier used a Macintosh standard mapping, see [[Asc]].
+
[[Chr]] is useful for creating characters that cannot easily be typed, such as tab, which is [[Chr]](9) and new line or carriage return (CR), which is [[Chr]](13). For example, if you [[ReadTextFile|read in a text file]], <code>x</code>, you can use <code>SplitText(x, Chr(13))</code> to split the file up at each new line character into an array of lines.
  
= Library =
+
== Examples ==
 +
:<code>[[Chr]](65) &rarr; 'A'</code>
 +
:<code>[[JoinText]]([[Chr]](945..969)) &rarr; "αβγδεζηθικλμνξοπρςστυφχψω"</code>
 +
:<code>[[Chr]](0x27000)</code> &rarr; '𧀀'
  
Text functions
+
== History ==
 
+
* Starting in [[Analytica 5.0]], the accepted range is 0 to 0x10FFFF, which includes the unicode supplemental planes 0x10000 to 0x10FFFF.
= See Also =
+
* In [[Analytica 4.5]] and [[Analytica 4.6]], «n» must be between 0 and 65535 = 0xFFFF.
 +
* Before [[Analytica 4.5]], «n» was limited to 0-255.
  
 +
== See Also ==
 
* [[Asc]]
 
* [[Asc]]
 
* [[SplitText]]
 
* [[SplitText]]
 +
* [[Text functions]]
 +
* [[Model File Character Encoding]]

Latest revision as of 22:22, 1 March 2017


Chr(n)

Returns the character as a text that corresponds to the numerical Unicode value «n» (a number between 0 and 1,114,111=0x10FFFF). Chr and Asc are inverses of each other, for example:

Chr(65) → ‘A’
Asc('A') → 65

Chr is useful for creating characters that cannot easily be typed, such as tab, which is Chr(9) and new line or carriage return (CR), which is Chr(13). For example, if you read in a text file, x, you can use SplitText(x, Chr(13)) to split the file up at each new line character into an array of lines.

Examples

Chr(65) → 'A'
JoinText(Chr(945..969)) → "αβγδεζηθικλμνξοπρςστυφχψω"
Chr(0x27000) → '𧀀'

History

  • Starting in Analytica 5.0, the accepted range is 0 to 0x10FFFF, which includes the unicode supplemental planes 0x10000 to 0x10FFFF.
  • In Analytica 4.5 and Analytica 4.6, «n» must be between 0 and 65535 = 0xFFFF.
  • Before Analytica 4.5, «n» was limited to 0-255.

See Also

Comments


You are not allowed to post comments.