@@ -3,32 +3,82 @@ id: string-char
33title : CHAR
44---
55
6- Return the character for each integer passed.
6+ import FunctionDescription from '@site/src /components/FunctionDescription';
7+
8+ <FunctionDescription description =" Introduced or updated: v1.2.752 " />
9+
10+
11+ Returns the character(s) for each integer passed. The function converts each integer to its corresponding Unicode character.
712
813## Syntax
914
1015``` sql
1116CHAR (N, ...)
17+ CHR(N)
1218```
1319
1420## Arguments
1521
16- | Arguments | Description |
17- | -----------| ----------------|
18- | N | Numeric Column |
22+ | Arguments | Description |
23+ | -----------| ---------------------------------------------------------------- |
24+ | N | Integer value(s) representing Unicode code points (0 to 2^32-1) |
1925
2026## Return Type
2127
22- ` BINARY `
28+ ` STRING `
29+
30+ ## Remarks
31+
32+ - Accepts any integer type (auto-casts to Int64).
33+ - Returns empty string ('') and logs an error for invalid code points.
34+ - ` chr ` is an alias for ` char ` .
35+ - NULL inputs result in NULL output.
2336
2437## Examples
2538
2639``` sql
27- SELECT CHAR (77 ,121 ,83 ,81 ,76 ) as a, a::String;
28- ┌────────────────────────┐
29- │ a │ a::string │
30- │ Binary │ String │
31- ├────────────┼───────────┤
32- │ 4D7953514C │ MySQL │
33- └────────────────────────┘
40+ -- Basic usage
41+ SELECT CHAR (65 , 66 , 67 );
42+ ┌───────┐
43+ │ char │
44+ │ String│
45+ ├───────┤
46+ │ ABC │
47+ └───────┘
48+
49+ -- Using the CHR alias
50+ SELECT CHR(68 );
51+ ┌───────┐
52+ │ chr │
53+ │ String│
54+ ├───────┤
55+ │ D │
56+ └───────┘
57+
58+ -- Creating a string from multiple code points
59+ SELECT CHAR (77 ,121 ,83 ,81 ,76 );
60+ ┌───────┐
61+ │ char │
62+ │ String│
63+ ├───────┤
64+ │ MySQL │
65+ └───────┘
66+
67+ -- Auto-casting from different integer types
68+ SELECT CHAR (CAST(65 AS UInt16));
69+ ┌───────┐
70+ │ char │
71+ │ String│
72+ ├───────┤
73+ │ A │
74+ └───────┘
75+
76+ -- NULL handling
77+ SELECT CHAR (NULL );
78+ ┌───────┐
79+ │ char │
80+ │ String│
81+ ├───────┤
82+ │ NULL │
83+ └───────┘
3484```
0 commit comments