protected Int32 stringToUInt32Array(
String source,
UInt32[ ] target,
UInt32 offset,
UInt32 length
)
{
Byte[ ] encodedChars = Encoding.Unicode.GetBytes( source );
// Following is clumsy but other option is make entire module run
// in 'unsafe' mode to allow casting byte to int array via IntPtr
Array.Clear( target, ( int ) offset, ( int ) length );
target[ offset ] = ( UInt32 ) ( ( 0x02 + encodedChars.Length ) | 0x03 << 0x08 );
if ( 0 != encodedChars.Length )
{
target[ offset] =
target[ offset ] |
( ( UInt32 ) encodedChars[ 0 ] | ( UInt32 ) encodedChars[ 1 ] << 0x08 ) << 0x10;
}
for( int index = 1; index < encodedChars.Length / 2; ++ index )
{
target[ offset + ( ( index + 1 ) / 2 ) ] |=
( 1 == ( index % 2 ) ) ?
( ( UInt32 ) encodedChars[ index * 2 ] | ( UInt32 ) encodedChars[ index * 2 + 1 ] << 0x08 ) :
( ( UInt32 ) encodedChars[ index * 2 ] | ( UInt32 ) encodedChars[ index * 2 + 1 ] << 0x08 ) << 0x10;
}
return 0;
}