我正在進行加密algotythm,我還需要加密德語單詞。所以我必須加密字符,例如:ü,ä或ö。將德文特殊字符放入字節數組
裏面我有一個功能:( 「?」 等等)
private static byte[] getBytesArray(string data)
{
byte[] array;
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
array = asciiEncoding.GetBytes(data);
return array;
}
但是,當數據爲 「ü」,在陣列返回的字節是63。我怎樣才能返回ü字節?
我也試過:
private static byte[] MyGetBytesArray(string data)
{
byte[] array;
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
Encoding enc = new UTF8Encoding(true, true);
array = enc.GetBytes(data);
return array;
}
但在這種情況下,我得到2個字節數組:195和188
使用'UTF8Encoding',而不是'ASCIIEncoding'。 –
根據定義,ASCII只能達到7Fh,並且這些德語字符在'7Fh'之上(請確認)。你可以試試'Encoding.Default'嗎? –
您可以使用1141作爲編碼根據http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx – t3hn00b