# class UString | Unicode string class. More...
Full name | `KJS::UString`
Definition | `#include <ustring.h>`
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- UString ()
- UString (char c)
- UString (const char *c)
- UString (const UChar *c, int length)
- UString (UChar *c, int length, bool copy)
- UString (const UString &)
- UString (const QString &)
- UString (const DOM::DOMString &)
- ~UString ()
- UString & append (const UString &)
- CString cstring () const
- char * ascii () const
- DOM::DOMString string () const
- QString qstring () const
- QConstString qconststring () const
- UString & operator= (const char *c)
- UString & operator= (const UString &)
- UString & operator+= (const UString &s)
- const UChar* data () const
- bool isNull () const
- bool isEmpty () const
- bool is8Bit () const
- int size () const
- UChar operator[] (int pos) const
- UCharReference operator[] (int pos)
- double toDouble () const
- unsigned long toULong (bool *ok = 0L) const
- int find (const UString &f, int pos = 0) const
- int rfind (const UString &f, int pos) const
- UString substr (int pos = 0, int len = -1) const

#### Public Static Methods

- static UString from (int i)
- static UString from (unsigned int u)
- static UString from (double d)

#### Public Members

- static UString null

## Detailed Description

UString () | ### UString

Constructs a null string.

UString (char c) | ### UString

Constructs a string from the single character c.

UString (const char *c) | ### UString

Constructs a string from a classical zero determined char string.

UString (const UChar *c, int length) | ### UString

Constructs a string from an array of Unicode characters of the specified length.

UString (UChar *c, int length, bool copy) | ### UString

If copy is false a shallow copy of the string will be created. That means that the data will NOT be copied and you'll have to guarantee that it doesn't get deleted during the lifetime of the UString object. Behaviour defaults to a deep copy if copy is true.

UString (const UString &) | ### UString

Copy constructor. Makes a shallow copy only.

UString (const QString &) | ### UString

Convenience declaration only ! You'll be on your own to write the implementation for a construction from QString.

Note: feel free to contact me if you want to see a dummy header for your favourite FooString class here !

UString (const DOM::DOMString &) | ### UString

Convenience declaration only ! See UString(const QString&).

~UString () | ### ~UString

Destructor. If this handle was the only one holding a reference to the string the data will be freed.

UString from (int i) | ### from

[static]

Constructs a string from an int.

UString from (unsigned int u) | ### from

[static]

Constructs a string from an unsigned int.

UString from (double d) | ### from

[static]

Constructs a string from a double.

UString & append (const UString &) | ### append

Append another string.

CString cstring () | ### cstring

[const]

Returns: The string converted to the 8-bit string type CString().

char * ascii () | ### ascii

[const]

Convert the Unicode string to plain ASCII chars chopping of any higher bytes. This method should only be used for *debugging* purposes as it is neither Unicode safe nor free from side effects. In order not to waste any memory the char buffer is static and *shared* by all UString instances.

DOM::DOMString string () | ### string

[const]

See also: UString(const, QString&).

QString qstring () | ### qstring

[const]

See also: UString(const, QString&).

QConstString qconststring () | ### qconststring

[const]

See also: UString(const, QString&).

UString & operator= (const char *c) | ### operator=

Assignment operator.

UString & operator= (const UString &) | ### operator=

Assignment operator.

UString & operator+= (const UString &s) | ### operator+=

Appends the specified string.

const UChar* data () | ### data

[const]

Returns: A pointer to the internal Unicode data.

bool isNull () | ### isNull

[const]

Returns: True if null.

bool isEmpty () | ### isEmpty

[const]

Returns: True if null or zero length.

bool is8Bit () | ### is8Bit

[const]

Use this if you want to make sure that this string is a plain ASCII string. For example, if you don't want to lose any information when using cstring() or ascii().

Returns: True if the string doesn't contain any non-ASCII characters.

int size () | ### size

[const]

Returns: The length of the string.

UChar operator[] (int pos) | ### operator[]

[const]

Const character at specified position.

UCharReference operator[] (int pos) | ### operator[]

Writable reference to character at specified position.

double toDouble () | ### toDouble

[const]

Attempts an conversion to a number. Apart from floating point numbers, the algorithm will recognize hexadecimal representations (as indicated by a 0x or 0X prefix) and +/- Infinity. Returns NaN if the conversion failed.

unsigned long toULong (bool *ok = 0L) | ### toULong

[const]

Attempts an conversion to an unsigned long integer. ok will be set according to the success.

int find (const UString &f, int pos = 0) | ### find

[const]

Returns: Position of first occurence of f starting at position pos. -1 if the search was not successful.

int rfind (const UString &f, int pos) | ### rfind

[const]

Returns: Position of first occurence of f searching backwards from position pos. -1 if the search was not successful.

UString substr (int pos = 0, int len = -1) | ### substr

[const]

Returns: The sub string starting at position pos and length len.

static UString null | ### null

Generated by: root@i386.ports.openbsd.org on Wed Apr 25 13:58:56 2001, using kdoc 2.0a53.