中文返回缓冲区 [英] Chinese in return buffer

查看:100
本文介绍了中文返回缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C Dll具有许多功能.其中一些通过char缓冲区返回非常大的数字.我在这些缓冲区中得到中文.我该如何安排这些缓冲区以获取缓冲区中的数字而不是中文符号?

I have C Dll with number of functions. Some of them return very big numbers by char buffers. I get Chinese in these buffers. What can I do for arranging these buffers for getting numbers in buffer and not Chinese symbols?

推荐答案

它们可能不是专门返回中文字符,而是一系列组成数字的字节.由于字节值在0到255之间(含0和255),因此如果尝试显示它们,它们将显示为奇数符号.

您将必须查看您的DLL文档,并找出返回的大量数字的格式:由于我们不知道您所指的DLL,所以我们甚至无法猜测到!您可能会发现DLL包含用于将非常大的数字与可打印的字符串进行相互转换的函数.
They probably aren''t returning Chinese characters specifically, but a sequence of bytes which form the number. Since the byte values are 0 to 255 inclusive, they are displayed as odd symbols if you try to display them.

You will have to look at your DLL documentation and find out what format the very large numbers are returned in: since we don''t know what DLL you are referring to, we can''t even guess this! You may find that the DLL contains functions for converting the very large numbers to and from printable strings.


int __stdcall RSA_EncryptMessage_Ex(char * pmsg, BSTR* bstrM, int nMsgSz, int nBits)
{
    int iSize = 0;
    wchar_t wcstring[KEYSIZE];

    if (RSA_EncryptMessage(chM, pmsg, chN, chD, chE, nMsgSz, nBits) != 0)
        return -1;

    iSize = 2*strlen(chM);
    _snwprintf(wcstring, iSize, L"%S (wchar_t *)", chM);
    *bstrM = SysAllocStringByteLen((LPCSTR)wcstring, iSize);

    return 0;
}


首先,通过参考变量.必须为BSTR类型.
其次,我将字符数组转换为宽字符. BSTR.这样就可以了!


First, variables by ref. must be of the type BSTR.
Second, I transformed the char array to wide char. BSTR. So, it''s working!


这篇关于中文返回缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆