|
1 |
| ---- |
2 |
| -title: Char function | Microsoft Docs |
3 |
| -description: Reference information for the Char function in Power Apps, including syntax and examples |
4 |
| -author: gregli-msft |
5 |
| -manager: kvivek |
6 |
| -ms.service: powerapps |
7 |
| -ms.topic: reference |
8 |
| -ms.custom: canvas |
9 |
| -ms.reviewer: tapanm |
10 |
| -ms.date: 03/01/2019 |
11 |
| -ms.author: gregli |
12 |
| -search.audienceType: |
13 |
| - - maker |
14 |
| -search.app: |
15 |
| - - PowerApps |
16 |
| ---- |
17 |
| -# Char function in Power Apps |
18 |
| - |
19 |
| -Translates a character code into a string. |
20 |
| - |
21 |
| -## Description |
22 |
| - |
23 |
| -The **Char** function translates a number into a string with the corresponding ASCII character. |
24 |
| - |
25 |
| -## Syntax |
26 |
| - |
27 |
| -**Char**( *CharacterCode* ) |
28 |
| - |
29 |
| -- *CharacterCode* - Required. ASCII character code to translate. |
30 |
| - |
31 |
| -## Examples |
32 |
| - |
33 |
| -| Formula | Description | Result | |
34 |
| -| --- | --- | --- | |
35 |
| -| **Char( 65 )** |Returns the character that corresponds to ASCII code 65. |"A" | |
36 |
| -| **Char( 105 )** |Returns the character that corresponds to ASCII code 105. |"i" | |
37 |
| -| **Char( 35 )** |Returns the character that corresponds to ASCII code 35. |"#" | |
38 |
| - |
39 |
| -### Display a character map |
40 |
| - |
41 |
| -1. On an empty screen in a tablet app, add a [**Gallery**](../controls/control-gallery.md) control with a **Blank Horizontal** layout, and then set these properties: |
42 |
| - |
43 |
| - - **Items**: `[0,1,2,3,4,5,6,7]` |
44 |
| - - **Width**: 800 |
45 |
| - - **Height**: 500 |
46 |
| - - **TemplateSize**: 100 |
47 |
| - - **TemplatePadding**: 0 |
48 |
| - |
49 |
| -1. Inside that gallery, add a **Gallery** control with a **Blank Vertical** layout, and then set these properties: |
50 |
| - |
51 |
| - - **Items**: `ForAll( [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], Value + ThisItem.Value * 16 )` |
52 |
| - - **Width**: 100 |
53 |
| - - **Height**: 500 |
54 |
| - - **TemplateSize**: 30 |
55 |
| - - **TemplatePadding**: 0 |
56 |
| - |
57 |
| - The value of the **Items** property multiplies 16 by the column number provided by the Value column of the **Items** property from the first gallery (0-7 in `ThisItem.Value`). The formula then adds the result to one of the row numbers from the second gallery (0-15 in the record scope that the [**ForAll**](function-forall.md) function provides). |
58 |
| - |
59 |
| -1. Inside the second (vertical) gallery, add a **Label** control, and set these properties: |
60 |
| - |
61 |
| - - **Text**: `ThisItem.Value` |
62 |
| - - **Width**: 50 |
63 |
| - |
64 |
| -1. Inside the second (vertical) gallery, add another **Label** control, and set these properties: |
65 |
| - |
66 |
| - - **Text**: `Char( ThisItem.Value )` |
67 |
| - - **Width**: 50 |
68 |
| - - **X**: 50 |
69 |
| - |
70 |
| -You've created a chart of the first 128 ASCII characters. Characters that appear as a small square can't be printed. |
71 |
| - |
72 |
| - |
73 |
| - |
74 |
| -To show the extended ASCII characters, set the **Items** property of the second gallery to this formula, which adds 128 to each character value: |
75 |
| - |
76 |
| -`ForAll( [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], Value + ThisItem.Value * 16 + 128)` |
77 |
| - |
78 |
| - |
79 |
| - |
80 |
| -To show the characters in a different font, set the **Font** property of the second label to a value such as **'Dancing Script'**. |
81 |
| - |
82 |
| - |
| 1 | +--- |
| 2 | +title: Char function | Microsoft Docs |
| 3 | +description: Reference information for the Char function in Power Apps, including syntax and examples |
| 4 | +author: gregli-msft |
| 5 | +manager: kvivek |
| 6 | +ms.service: powerapps |
| 7 | +ms.topic: reference |
| 8 | +ms.custom: canvas |
| 9 | +ms.reviewer: tapanm |
| 10 | +ms.date: 07/17/2020 |
| 11 | +ms.author: gregli |
| 12 | +search.audienceType: |
| 13 | + - maker |
| 14 | +search.app: |
| 15 | + - PowerApps |
| 16 | +--- |
| 17 | +# Char function in Power Apps |
| 18 | + |
| 19 | +Translates a character code into a string. |
| 20 | + |
| 21 | +## Description |
| 22 | + |
| 23 | +The **Char** function translates a number into a string with the corresponding ASCII character. |
| 24 | + |
| 25 | +## Syntax |
| 26 | + |
| 27 | +**Char**( *CharacterCode* ) |
| 28 | + |
| 29 | +- *CharacterCode* - Required. ASCII character code to translate. |
| 30 | + |
| 31 | +## Examples |
| 32 | + |
| 33 | +| Formula | Description | Result | |
| 34 | +| --- | --- | --- | |
| 35 | +| **Char( 65 )** |Returns the character that corresponds to ASCII code 65. |"A" | |
| 36 | +| **Char( 105 )** |Returns the character that corresponds to ASCII code 105. |"i" | |
| 37 | +| **Char( 35 )** |Returns the character that corresponds to ASCII code 35. |"#" | |
| 38 | + |
| 39 | +### Display a character map |
| 40 | + |
| 41 | +1. On an empty screen in a tablet app, add a [**Gallery**](../controls/control-gallery.md) control with a **Blank Horizontal** layout, and then set these properties: |
| 42 | + |
| 43 | + - **Items**: `Sequence( 8, 0, 16 ) As HighNibble` |
| 44 | + - **Width**: `Parent.Width` |
| 45 | + - **Height**: `Parent.Height` |
| 46 | + - **TemplateSize**: `Parent.Width / 8` |
| 47 | + - **TemplatePadding**: 0 |
| 48 | + - **X**: 0 |
| 49 | + - **Y**: 0 |
| 50 | + |
| 51 | +1. Inside that gallery, add a **Gallery** control with a **Blank Vertical** layout, and then set these properties: |
| 52 | + |
| 53 | + - **Items**: `Sequence( 16, HighNibble.Value ) As FullCode` |
| 54 | + - **Width**: `Parent.Width / 8` |
| 55 | + - **Height**: `Parent.Height` |
| 56 | + - **TemplateSize**: `Parent.Height / 16` |
| 57 | + - **TemplatePadding**: 0 |
| 58 | + - **X**: 0 |
| 59 | + - **Y**: 0 |
| 60 | + |
| 61 | +1. Inside the second (vertical) gallery, add a **Label** control, and set these properties: |
| 62 | + |
| 63 | + - **Text**: `FullCode.Value` |
| 64 | + - **Width**: `Parent.Width / 2` |
| 65 | + - **X**: 0 |
| 66 | + - **Y**: 0 |
| 67 | + - **Align**: `Center` |
| 68 | + - **FontWeight**: `Bold` |
| 69 | + - **Size**: 24 |
| 70 | + |
| 71 | +1. Inside the second (vertical) gallery, add another **Label** control, and set these properties: |
| 72 | + |
| 73 | + - **Text**: `Char( FullCode.Value )` |
| 74 | + - **Width**: `Parent.Width / 2` |
| 75 | + - **X**: `Parent.Width / 2` |
| 76 | + - **Y**: 0 |
| 77 | + - **FontWeight**: `Bold` |
| 78 | + - **Size**: 24 |
| 79 | + |
| 80 | +You've created a chart of the first 128 ASCII characters. Characters that appear as a small square can't be printed. |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | +If you want to see how **FullCode.Value** gets its values. Let's begin with the outer horizontal gallery. Its **Items** property uses the **Sequence** function to create 8 columns, starting with 0 with increments of 16: |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +Nested within this gallery is another vertical gallery. Its **Items** property fills in the gap left by the increment of 16 from the outer gallery: |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +To show the extended ASCII characters, it is a simple matter of changing the starting point for the chart, set in the Sequence function for the outer gallery: |
| 93 | + |
| 94 | +`Sequence( 8, 128, 16 ) As HighNibble` |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +Finally, to show the characters in a different font, set the **Font** property of the second label to a value such as **'Dancing Script'**. |
| 99 | + |
| 100 | + |
0 commit comments