同一个字符串values="标题=123 \xFF 正文=lsdfj";
在VC里显示为 标题=123 正文=lsdfj
在.NET里显示为 标题=123 ÿ 正文=lsdfj
为什么?我在VC里写的DLL里边有一分割函数是根据 \xFF 对字符串进行分割
而在.NET里进行平台调用后调用该分割函数发现不起作用了,为什么?
在VC里显示为 标题=123 正文=lsdfj
在.NET里显示为 标题=123 ÿ 正文=lsdfj
为什么?我在VC里写的DLL里边有一分割函数是根据 \xFF 对字符串进行分割
而在.NET里进行平台调用后调用该分割函数发现不起作用了,为什么?
char c = System.Convert.ToChar( b );
string str = ="标题=123" +c+ " 正文=lsdfj";
char c = System.Convert.ToChar( b );
string str = ="标题=123" +c+ " 正文=lsdfj";
___________________________________________结果和直接赋值一样,分割函数还是不起作用啊
______________________________问题是在VC写的DLL里边那分割函数是用\xFF进行分割的,我这只有一个.DLL文件,没法改啊,
有没有其它方法啊?
string str = "这是一二三";
int nCount = System.Text.Encoding.Default.GetByteCount(str);
byte[] ba = System.Text.Encoding.Default.GetBytes( str );
byte[] abtemp = new byte[ nCount +1 ];
ba.CopyTo( abtemp , 0 );
abtemp[nCount] = b;
用byte[]试试
再将temp传入?
试了一下,还是不行
ms-help://MS.MSDNQTR.2003FEB.2052/vccore/html/_core_managing_string_data.htm
DWORD InsertRecord
(PCSTR Name,
PCSTR Owner,
PCSTR Values, /* 新记录中各字段的值,或待添加的词语列表 */
PCSTR Password);在.NET中定义为
[DllImport("Api32.dll",CharSet=System.Runtime.InteropServices.CharSet.Ansi,EntryPoint="InsertRecord", ExactSpelling=true)]
public static UInt32 InsertRecord
(string name,
string owner,
string values, /* 新记录中各字段的值,或待添加的词语列表 */
string password
)
就是将字符串string test="标题=wzj\xFF正文=@d:\\2.txt";中的\xFF字符位置的字符改成255
但是无论怎么改,比如改成string test="标题=wzj\x98正文=@d:\\2.txt";
然后byte[] t=System.Text.Encoding.Default.GetBytes( test );
它的t[8]字节处也就是\x98字符位置的ACSII码都不会超过63
char c = System.Convert.ToChar( b );