|
- Author:
- kris (IP: 68.122.70.98)
- Timestamp:
- 03/16/07 18:33:50 (17 years ago)
- Comment:
added D formatting
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TutCSharpFormatterComments
v2 |
v3 |
|
5 | 5 | The interesting code is in the tango.text.convert.Layout module, in a templated class called Layout(T). You can instantiate the template with char, dchar, or wchar types, and use the !OpCall syntax to format your strings, like this: |
---|
6 | 6 | {{{ |
---|
| 7 | #!d |
---|
7 | 8 | import tango.text.convert.Layout; |
---|
8 | 9 | |
---|
21 | 22 | You might consider the sprint() method also, which avoids heap activity. Also, if you're already using Stdout or Stderr, it can be simpler to apply the Layout instance exposed there instead: |
---|
22 | 23 | {{{ |
---|
| 24 | #!d |
---|
23 | 25 | char[256] out = void; |
---|
24 | 26 | auto content = Stdout.layout.sprint (out, "This is the thing: '{}'", thing); |
---|
27 | 29 | One might also utilize the locale enabled extensions in a similar manner, by using tango.text.locale.Locale instead of Layout. Locale is a derivative of Layout, so all formatting methods are common with Locale adding support for more sophisticated formatting options along with culture-specific currency, time and date consideration: |
---|
28 | 30 | {{{ |
---|
| 31 | #!d |
---|
29 | 32 | import tango.text.locale.Locale; |
---|
30 | 33 | |
---|
36 | 39 | It's also possible to make Stdout and Stderr locale-aware, by replacing the (shared) layout instance: |
---|
37 | 40 | {{{ |
---|
| 41 | #!d |
---|
38 | 42 | Stdout.layout = new Locale (Culture.getCulture ("fr-FR")); |
---|
39 | 43 | }}} |
|
|
|
|
|
Copyright © 2006-2024 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic