Static methods that help to print literals, such as EscapeCStyle which escapes special characters with backslashes.
More...
Source file:
Static methods that help to print literals, such as EscapeCStyle which escapes special characters with backslashes.
|
| static char | HexDigitChar (int value) |
| | Gets the hex digit character for the specified value, or '?' if the value is not in the range 0...15. Uses uppercase. More...
|
| |
| static string | EscapeCStyle (UString s, EscapeC flags=EscapeC.Default) |
| | Escapes characters in a string using C style, e.g. the string "Foo\"
"</c> maps to <c>"Foo\"\
" by default. More...
|
| |
| static string | EscapeCStyle (UString s, EscapeC flags, char quoteType) |
| | Escapes characters in a string using C style. More...
|
| |
| static bool | EscapeCStyle (int c, StringBuilder @out, EscapeC flags=EscapeC.Default, char quoteType='\0') |
| | Writes a character c to a StringBuilder, either as a normal character or as a C-style escape sequence. More...
|
| |
| static string | IntegerToString (long value, string prefix="", int @base=10, int separatorInterval=3, char separatorChar='_') |
| | Converts an integer to a string, optionally with separator characters for readability. More...
|
| |
|
static string | IntegerToString (ulong value, string prefix="", int @base=10, int separatorInterval=3, char separatorChar='_') |
| |
| static StringBuilder | AppendIntegerTo (StringBuilder target, long value, string prefix="", int @base=10, int separatorInterval=3, char separatorChar='_') |
| | Same as IntegerToString(long, string, int, int, char) except that the target StringBuilder must be provided as a parameter. More...
|
| |
|
static StringBuilder | AppendIntegerTo (StringBuilder target, ulong value, string prefix="", int @base=10, int separatorInterval=3, char separatorChar='_') |
| |
◆ AppendIntegerTo()
| static StringBuilder Loyc.Syntax.PrintHelpers.AppendIntegerTo |
( |
StringBuilder |
target, |
|
|
long |
value, |
|
|
string |
prefix = "", |
|
|
int @ |
base = 10, |
|
|
int |
separatorInterval = 3, |
|
|
char |
separatorChar = '_' |
|
) |
| |
|
inlinestatic |
Same as IntegerToString(long, string, int, int, char) except that the target StringBuilder must be provided as a parameter.
- Parameters
-
| value | Integer to be converted |
| prefix | A prefix to insert before the number, but after the '-' sign, if any (e.g. "0x" for hex). Use "" for no prefix. |
| base | Number base (e.g. 10 for decimal, 2 for binary, 16 for hex). Must be in the range 2 to 36. |
| separatorInterval | Number of digits in a group (use 0 or less to disable digit separators) |
| separatorChar | Digit group separator |
- Returns
- The target StringBuilder.
Referenced by Loyc.Syntax.PrintHelpers.IntegerToString().
◆ EscapeCStyle() [1/3]
| static bool Loyc.Syntax.PrintHelpers.EscapeCStyle |
( |
int |
c, |
|
|
StringBuilder @ |
out, |
|
|
EscapeC |
flags = EscapeC.Default, |
|
|
char |
quoteType = '\0' |
|
) |
| |
|
inlinestatic |
Writes a character c to a StringBuilder, either as a normal character or as a C-style escape sequence.
- Parameters
-
| flags | Specifies which characters should be escaped. |
| quoteType | Specifies a character that should always be escaped (typically one of ' " `) |
- Returns
- true if an escape sequence was emitted, false if not.
EscapeC.HasLongEscape can be used to force a 6-digit unicode escape; this may be needed if the next character after this one is a digit.
◆ EscapeCStyle() [2/3]
| static string Loyc.Syntax.PrintHelpers.EscapeCStyle |
( |
UString |
s, |
|
|
EscapeC |
flags, |
|
|
char |
quoteType |
|
) |
| |
|
inlinestatic |
◆ EscapeCStyle() [3/3]
◆ HexDigitChar()
| static char Loyc.Syntax.PrintHelpers.HexDigitChar |
( |
int |
value | ) |
|
|
inlinestatic |
Gets the hex digit character for the specified value, or '?' if the value is not in the range 0...15. Uses uppercase.
◆ IntegerToString()
| static string Loyc.Syntax.PrintHelpers.IntegerToString |
( |
long |
value, |
|
|
string |
prefix = "", |
|
|
int @ |
base = 10, |
|
|
int |
separatorInterval = 3, |
|
|
char |
separatorChar = '_' |
|
) |
| |
|
inlinestatic |
Converts an integer to a string, optionally with separator characters for readability.
- Parameters
-
| value | Integer to be converted |
| prefix | A prefix to insert before the number, but after the '-' sign, if any (e.g. "0x" for hex). Use "" for no prefix. |
| base | Number base (e.g. 10 for decimal, 2 for binary, 16 for hex). Must be in the range 2 to 36. |
| separatorInterval | Number of digits in a group |
| separatorChar | Digit group separator |
- Returns
- The number as a string.
Example: IntegerToString(-1234567, "0", 10, 3, '\'') == "-01'234'567"
References Loyc.Syntax.PrintHelpers.AppendIntegerTo().