mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 22:02:49 -06:00
New Core Tutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@10538 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
dd88feaf2e
commit
6c22e727de
37 changed files with 3125 additions and 0 deletions
33
tutorial/CoreTutorial/WString.cpp
Normal file
33
tutorial/CoreTutorial/WString.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "Tutorial.h"
|
||||
|
||||
void WStringTutorial()
|
||||
{
|
||||
/// .WString
|
||||
|
||||
/// String works with 8 bit characters. For 16-bit character encoding use `WString`. Both
|
||||
/// classes are closely related and share most of interface methods. U++ also provides
|
||||
/// conversions between `String` and `WString` and you can also use 8 bit string literals with
|
||||
/// `WString`. Conversion is ruled by current default character set. Default value of default
|
||||
/// character set is `CHARSET_UTF8`. This conversion is also used in `WString::ToString`,
|
||||
/// e.g. when putting `WString` to log:
|
||||
|
||||
WString x = "characters 280-300: "; // you can assign 8-bit character literal to WString
|
||||
for(int i = 280; i < 300; i++)
|
||||
x.Cat(i);
|
||||
|
||||
DUMP(x);
|
||||
|
||||
/// `ToString` converts `WString` to `String`:
|
||||
|
||||
String y = x.ToString();
|
||||
DUMP(y);
|
||||
|
||||
/// `ToWString` converts `String` to `WString`:
|
||||
|
||||
y.Cat(" (appended)"); // you can use 8-bit character literals in most WString operations
|
||||
x = y.ToWString();
|
||||
|
||||
DUMP(x);
|
||||
|
||||
///
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue