Difference between revisions of "Chr"

From Xojo Documentation

m
 
Line 7: Line 7:
 
|text = Returns the character whose Unicode code point is passed. }}
 
|text = Returns the character whose Unicode code point is passed. }}
  
==Syntax==
+
== Usage ==
''result''='''Chr'''(''value'')
+
''result'' = '''Chr'''(''value'')
 
{| class="genericTable"
 
{| class="genericTable"
 
 
! width=15% | Part
 
! width=15% | Part
 
 
! width=15% | Type
 
! width=15% | Type
 
 
! width=55% | Description
 
! width=55% | Description
 
|-
 
|-
 
|result
 
|result
 
 
|[[String]]
 
|[[String]]
 
|The character whose Unicode code point was passed.
 
|The character whose Unicode code point was passed.
 
 
|-
 
|-
 
|value
 
|value
 
 
|[[Integer]]
 
|[[Integer]]
 
|The numeric value ("code point") of the character you want, which must be a valid Unicode character.  
 
|The numeric value ("code point") of the character you want, which must be a valid Unicode character.  
Line 33: Line 27:
 
The '''Chr''' function returns a string in ASCII encoding for values less than 128 and a UTF-8 encoded string for all other values. If you need to control the exact byte value, you should instead call [[ChrB]].
 
The '''Chr''' function returns a string in ASCII encoding for values less than 128 and a UTF-8 encoded string for all other values. If you need to control the exact byte value, you should instead call [[ChrB]].
  
==Examples==
+
== Sample Code ==
These examples use the '''Chr''' function to return the characters whose ASCII values are specified.
+
This code use the '''Chr''' function to return the characters whose ASCII values are specified.
 
 
 
<rbcode>
 
<rbcode>
 
Dim tab, CR As String
 
Dim tab, CR As String
Line 44: Line 37:
  
 
==See Also==
 
==See Also==
[[Asc]], [[ChrB]], [[Encoding]], [[InStr]], [[Left]], [[Len]], [[Mid]], [[Right]] functions; [[EndOfLine]], [[TextEncoding]] classes; [[Encodings]] module.
+
[[Asc]], [[ChrB]], [[Encoding]], [[InStr]], [[Left]], [[Len]], [[Mid]], [[Right]], [[Text.FromUnicodeCodepoint]] functions; [[EndOfLine]], [[TextEncoding]] classes; [[Encodings]] module; [[String]], [[Text]] data types
 
 
[http://developer.xojo.com/text$FromUnicodeCodepoint Text.FromUnicodeCodepoint]
 
  
 
[[Category:Text_Strings]]
 
[[Category:Text_Strings]]

Latest revision as of 19:27, 22 January 2019

Method

Returns the character whose Unicode code point is passed.

Usage

result = Chr(value)

Part Type Description
result String The character whose Unicode code point was passed.
value Integer The numeric value ("code point") of the character you want, which must be a valid Unicode character.

Notes

The Chr function returns a string in ASCII encoding for values less than 128 and a UTF-8 encoded string for all other values. If you need to control the exact byte value, you should instead call ChrB.

Sample Code

This code use the Chr function to return the characters whose ASCII values are specified.

Dim tab, CR As String
tab = Chr(9) // returns a tab
CR = Chr(13) // returns carriage return
CR = Encodings.ASCII.Chr(13) // also returns carriage return

See Also

Asc, ChrB, Encoding, InStr, Left, Len, Mid, Right, Text.FromUnicodeCodepoint functions; EndOfLine, TextEncoding classes; Encodings module; String, Text data types