Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Utf8 Class Reference

List of all members.

Static Public Member Functions

char[] encode (wchar[] input, char[] output, inout uint consumed)
wchar[] decode (char[] input, wchar[] output, inout uint consumed)
char[] encode (wchar[] input)
wchar[] decode (char[] input)

Static Private Member Functions

 this ()

Static Private Attributes

IOException InvalidEncoding
IOException InvalidDecoding

Detailed Description

Fast UTF-8 to Unicode transcoder. These are really sensitive to small changes on 32bit x86 devices, because the register set of those devices is so small. Beware of subtle changes which might extend the execution-period by as much as 200% ...

These routines were tuned on an Intel P3; other devices may work more efficiently with a slightly different approach, though this is likely to be reasonably optimal on AMD x86 CPUs also. These algorithms could benefit significantly from those extra AMD64 registers.

Note that foreach can produce noticeable more efficient code than equivalent for() loops, with either indices or pointers. The 0.98 compiler version exhibited some rather erratic behavior over the course of testing: in particular, elapsed time of method execution is noticeably dependent upon its physical location within the file (or, more specifically, the enclosing class). Yes, it sure sounds crazy that if you switch the order of encode() with decode() that they will consistently execute slower than as currently arranged.

Finally, please note that these are between 5 and 30 times faster than equivalent functions in the std.utf Phobos module (dependent upon the mix of char values). Those functions (strangely) often allocate memory on a character basis, so will become significantly slower where there's heap-contention by multiple threads.

Definition at line 70 of file Utf8.d.


Member Function Documentation

this  )  [inline, static, private]
 

Definition at line 79 of file Utf8.d.

References InvalidDecoding, and InvalidEncoding.

char [] encode wchar[]  input,
char[]  output,
inout uint  consumed
[inline, static]
 

Encode UTF-8 up to a maximum of 3 bytes long (four, five & six byte variations are not supported). Throws an exception where the input wchar is greater than 0xd7ff.

Definition at line 93 of file Utf8.d.

References InvalidEncoding.

Referenced by encode().

wchar [] decode char[]  input,
wchar[]  output,
inout uint  consumed
[inline, static]
 

Decode UTF-8 produced by the above encode() method. This executes notably faster than the validating version.

Definition at line 148 of file Utf8.d.

References InvalidDecoding.

Referenced by decode().

char [] encode wchar[]  input  )  [inline, static]
 

Encode UTF-8 up to a maximum of 3 bytes long (four, five & six byte variations are not supported). Throws an exception where the input wchar is greater than 0xd7ff.

Definition at line 204 of file Utf8.d.

References encode().

wchar [] decode char[]  input  )  [inline, static]
 

Decode UTF-8 produced by the above encode() method. This executes notably faster than the validating version.

Definition at line 219 of file Utf8.d.

References decode().


Member Data Documentation

IOException InvalidEncoding [static, private]
 

Definition at line 72 of file Utf8.d.

Referenced by encode(), and this().

IOException InvalidDecoding [static, private]
 

Definition at line 73 of file Utf8.d.

Referenced by decode(), and this().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:14 2004 for Mango by doxygen 1.3.6