[wiki:TextToolsComments Leave Comments, Critiques, and Suggestions Here] == Find, Replace and friends == The [../docs/current/tango.text.Util.html tango.text.Util] is a collection of templated helper functions. The module doc (previous link) has a summary and usage examples. The contained functions can handle UTF8/16/32. Note: you can also use generic array functions on a string. See [../docs/current/tango.core.Array.html tango.core.Array] {{{ #!d import tango.text.Util; void test1(){ locate( "abcdef", "cd" ); // returns 2 } }}} [../docs/current/tango.text.Util.html tango.text.Util] also contains are very lightweight layouter that allows the composition of strings in an easy and efficient way. However it can only handle string arguments and doesn't do any conversion. {{{ #!d import tango.text.Util; void test1(){ char[100] buffer = void; // save the time for initialization (=void) char[] result = layout( buffer, "%1 is after %0", "zero", "one" ); // result is "one is after zero" } }}} [../docs/current/tango.text.convert.Format.html tango.text.convert.Format] offers more power through conversions and formatting: {{{ #!d import tango.text.convert.Format; void test1(){ char[] result = Format.convert( buffer, "{1} is after {0}", 98, 99 ); // result is "99 is after 98" } }}} == Regular Expressions == Regular expressions lets you search for special patterns. You can retrieve parts of the match and do search replace actions.[[br]] Please see the module documentation [../docs/current/tango.text.Regex.html tango.text.Regex]. == Ascii and Unicode == The Ascii module offers functions for {{{toLower()}}}, {{{toUpper()}}}, {{{compare()}}}, {{{icompare()}}}.[[br]] Please see the module documentation [../docs/current/tango.text.Ascii.html tango.text.Ascii] '''Note:''' Ascii is only the character value 0..127, everything above is something else. In D the char type is UTF8 which is different to eg. ISO-8859-1 (fequently confused with Ascii). If you need to convert from or to something else then Ascii, an external library is needed. E.g. see the mango project, there is a binding to the ICU lib, that can hanlde every encoding. The [../docs/current/tango.text.Unicode.html tango.text.Unicode] offers also test and conversion functions for single Unicode characters. E.g. {{{toLower()}}}, {{{toUpper()}}}, {{{isSpace()}}}, {{{isPrintable()}}}, ... [[br]] Please see the module documentation [../docs/current/tango.text.Unicode.html tango.text.Unicode] '''Note:''' to convert whole unicode string from one encoding into another (utf8/16/32) see [wiki:ChapterConversions#Utf Chapter Conversions - Utf] == Store and manipulate Text == [../docs/current/tango.text.Text.html tango.text.Text] == INI Files aka Properties == The Properties module has the static {{{load()}}} and {{{save()}}} functions, for loading Property files. This is a file format, where each line is of the format {{{ # comment key = value }}} Please see the module documentation [../docs/current/tango.io.stream.Map.html tango.io.stream.Map] {{{ import tango.io.stream.Map; import tango.io.device.Array; auto buf = new Array("name=tango\r\npath=D:\\tango"); char[][ char[] ] map; auto input = new MapInput!(char)(buf); input.load(map); }}} == Links == * [wiki:ChapterLocale Chapter Locale] Given some text, a file, or a buffer, this will emit all lines contained: [[Image(source:/trunk/doc/images/LineIterator.gif)]] High level representation of a text string, with support for insert, remove, append, printf-style formatting, layout, utf conversion, custom comparison, etc. Also includes an immutable variant: [[Image(source:/trunk/doc/images/String.gif)]]