Escaping characters: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 52: Line 52:
Tricky, isn't it?
Tricky, isn't it?
|-
|-
| '''Any number of percent symbols'''  || String s = "aaa%bbb"; ''or'' String s="aaa%%bbb"; || 97 97 97 37 98 98 98  or 97 97 97 37 37 98 98 98 || The string will be stored in memory exactly as you typed it in. Trouble may arise only if you decide to use that particular String as the first parameter of the ''String.Format'' or ''Display'' function.
| '''Any number of percent symbols'''  || String s = "aaa%bbb"; ''or'' String s="aaa%%bbb"; || 97 97 97 37 98 98 98  or 97 97 97 37 37 98 98 98 || The string will be stored in memory exactly as you typed it in. Trouble may arise only if you decide to use that particular String as the first parameter of the ''String.Format'' or ''Display'' function (read further).
|}
|}


Line 70: Line 70:
* What you type in the "Text" property of the Label control is ''exactly''  what will be in memory. No escape characters apply.
* What you type in the "Text" property of the Label control is ''exactly''  what will be in memory. No escape characters apply.
* What will appear in the Label preview (in the GUI Editor, on the left) is rendered following the rules described in this page for Labels (read further).
* What will appear in the Label preview (in the GUI Editor, on the left) is rendered following the rules described in this page for Labels (read further).


{| class="wikitable"
{| class="wikitable"
Line 79: Line 80:
| aaa\[bbb || aaa[bbb || See Label rendering rules.
| aaa\[bbb || aaa[bbb || See Label rendering rules.
|-
|-
| aaa\\\\[bbb || aaa[bbb || See Label rendering rules. All the backslashes get swallowed up at once!
| aaa\\\\[bbb || aaa[bbb || See Label rendering rules. BEFORE AGS 3.4patch3: All the backslashes get swallowed up at once! FROM AGS3.4 patch3 : Same behaviour as everywhere else. Every backslash counts.
|-
|-
| aaa\bbb || aaa\bbb || (identical) See Label rendering rules.
| aaa\bbb || aaa\bbb || (identical) See Label rendering rules.
Line 88: Line 89:
|}
|}


'''IMPORTANT NOTE:''' There was a bug in some versions of AGS older than 3.2 : typing aaa\[bbb in the Text property of a Label would render it as follows in the Label:
{| class="wikitable"
| aaa\<br>bbb
|}


<big>'''2) At runtime, in a Label or a Display()'''</big>
<big>'''2) At runtime, in a Label or a Display()'''</big>
Line 100: Line 106:
| aaa\[bbb || aaa[bbb || The brace's special behaviour is disabled if it's preceded by one or more backslashes. The backslashes are not rendered.
| aaa\[bbb || aaa[bbb || The brace's special behaviour is disabled if it's preceded by one or more backslashes. The backslashes are not rendered.
|-
|-
| aaa\\\\[bbb || aaa[bbb || Please note that ''all'' the backslashes before a '[' don't get rendered.<br>Not only do they not get rendered, but they get '''deleted from the String''' (in-memory) if you make use of any of the following functions: '''Append''', '''AppendChar''', '''Replace''', etc. Also when you do a ''string'' -> ''String'' conversion (Reminder: ''string'' is the old-style AGS string, while ''String'' is the new-style AGS string since 3.x).<br>It doesn't seem to happen when you use ''String.Chars[i]''
| aaa\\\\[bbb || aaa[bbb || BEFORE AGS 3.4 patch 3: Please note that ''all'' the backslashes before a '[' don't get rendered.<br>Not only do they not get rendered, but they get '''deleted from the String''' (in-memory) if you make use of any of the following functions: '''Append''', '''AppendChar''', '''Replace''', etc. Also when you do a ''string'' -> ''String'' conversion (Reminder: ''string'' is the old-style AGS string, while ''String'' is the new-style AGS string since 3.x).<br>It doesn't seem to happen when you use ''String.Chars[i]'' STARTING FROM AGS 3.4 patch 3 : Every backslash counts. \[ gives [, \\ gives \, etc.
|-
|-
| aaa\bbb || aaa\bbb || The string gets rendered exactly as in memory, as the backslashes are not followed by '''['''.
| aaa\bbb || aaa\bbb || The string gets rendered exactly as in memory, as the backslashes are not followed by '''['''.
Line 109: Line 115:
|-
|-
| aaa%%ddd || '''In Label.Text:''' aaa%%ddd<br>'''In Display:''' aaa%ddd || '''%''' is a special character meant for formatting Strings, as in ''String s = String.Format("The value of i is %d", i);''.<br>In Labels, it will have no effect. However the ''Display'' function works the same way as ''String.Format'', so if you want to display ''one'' percent symbol, you must have ''two'' in your string.
| aaa%%ddd || '''In Label.Text:''' aaa%%ddd<br>'''In Display:''' aaa%ddd || '''%''' is a special character meant for formatting Strings, as in ''String s = String.Format("The value of i is %d", i);''.<br>In Labels, it will have no effect. However the ''Display'' function works the same way as ''String.Format'', so if you want to display ''one'' percent symbol, you must have ''two'' in your string.
|-
| aaa%%bbb || aaa%bbb || A double percent in memory is rendered as a single percent on-screen
|}
|}


132

edits