
iz@bel
(usa Ubuntu)
Enviado em 06/06/2008 - 18:35h
Bom, eu achei esse exemplo no Oracle (google)
Vê se te ajuda
###########################################
System;
System.Text;
SamplesEncoding {
Main() {
[] myChars = [] { 'z', 'a', '\u0306', '\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };
Encoding u7 = Encoding.UTF7;
Encoding u8 = Encoding.UTF8;
Encoding u16LE = Encoding.Unicode;
Encoding u16BE = Encoding.BigEndianUnicode;
Encoding u32 = Encoding.UTF32;
PrintCountsAndBytes( myChars, u7 );
PrintCountsAndBytes( myChars, u8 );
PrintCountsAndBytes( myChars, u16LE );
PrintCountsAndBytes( myChars, u16BE );
PrintCountsAndBytes( myChars, u32 );
}
PrintCountsAndBytes( [] chars, Encoding enc ) {
Console.Write( , enc.ToString() );
iBC = enc.GetByteCount( chars );
Console.Write( , iBC );
iMBC = enc.GetMaxByteCount( chars.Length );
Console.Write( , iMBC );
byte[] bytes = enc.GetBytes( chars );
PrintHexBytes( bytes );
}
PrintHexBytes( byte[] bytes ) {
(( bytes == ) || ( bytes.Length == 0 ))
Console.WriteLine( );
{
( i = 0; i < bytes.Length; i++ )
Console.Write( , bytes[i] );
Console.WriteLine();
}
}
}