本文介绍了将32位值编码为ANSI,包括空(00)字节吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将32位二进制值放入剪贴板.用户单击一个按钮(复制二进制"),然后我希望该按钮将我代码中32位值的ANSI二进制编码值放入剪贴板.这是我正在尝试的代码:

I am trying place a 32bit binary value into the clipboard. The user hits a button ("Copy Binary") and I want that button to place the ANSI binary encoded value of the 32 bit value in my code into the clipboard. Here is the code I am trying:

//byte[] bytes contains my 32 bit value as a 4 byte array.

            Clipboard.SetData(System.Windows.DataFormats.Text, Encoding.Default.GetString(bytes));



如果字节"中的值不包含"00",即0x12345678,则此方法可以正常工作.

但是,如果值为0x12005678,它将仅在编码0x12后停止,并且我的剪贴板中只有一个字节.



This works correctly if the values in "bytes" doesn''t contain a "00", i.e. 0x12345678.

However, if the value is 0x12005678 it will stop after encoding just 0x12 and I will only have one byte in my clipboard.

How can I make sure that the entire byte array is encoded?

推荐答案



这篇关于将32位值编码为ANSI,包括空(00)字节吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 10:19