Difference between revisions of "Chr"

From Xojo Documentation

(See Also)
 
(One intermediate revision by the same user not shown)
Line 31: Line 31:
 
This code 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
+
Var tab, CR As String
 
tab = Chr(9) // returns a tab
 
tab = Chr(9) // returns a tab
 
CR = Chr(13) // returns carriage return
 
CR = Chr(13) // returns carriage return
Line 38: Line 38:
  
 
==See Also==
 
==See Also==
[[Asc]], [[ChrB]], [[Encoding]], [[InStr]], [[Left]], [[Len]], [[Mid]], [[Right]], [[Text.FromUnicodeCodepoint]] functions; [[EndOfLine]], [[TextEncoding]] classes; [[Encodings]] module; [[String]], [[Text]] data types
+
[[Asc]], [[Encoding]], [[String.IndexOf]], [[Left]], [[Len]], [[Mid]], [[Right]] functions; [[EndOfLine]], [[TextEncoding]] classes; [[Encodings]] module; [[String]] data type
  
 
[[Category:Text_Strings]]
 
[[Category:Text_Strings]]

Latest revision as of 19:48, 4 April 2021

fa-info-circle-32.png
Chr (the global function) is here for compatibility with Visual Basic. You should instead use TextEncoding.Chr, for example Encodings.UTF8.Chr(9) for a tab.
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.

Var 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, Encoding, String.IndexOf, Left, Len, Mid, Right functions; EndOfLine, TextEncoding classes; Encodings module; String data type