transcodeFrom中的异常 [英] Exception in transcodeFrom

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

问题描述

我需要将字符串更改为utf8字节.

当我将RégionEstçensùs"字符串传递给"transcodeFrom"时,它将失败.

我不确定我通过的方式是否正确.

谁能帮我?通过提供一些信息,我对此并不陌生.

在此先感谢

我需要将字符串更改为utf8字节.
这是我的代码:

I need to change string to utf8 bytes.

When I pass "Région Est çensùs" string to "transcodeFrom" it fails.

I am not sure I am passing it in a right way.

Can any one help me? By giving some info, I am new to this.

Thanks in advance

I need to change string to utf8 bytes.
Here is my code:

const char * TestStr;//is having "Région Est çensùs"
size_t len = strlen(TestStr)+ 1;
unsigned int str;
unsigned char* Sizes = new unsigned char[len];
 
try
{
 
transcodeFrom((XMLByte *)TestStr,(unsigned int)(len),str,(unsigned int)(len),str,(unsigned char *)Sizes);
 
}
catch(...)
{
     something
}



当我尝试运行此控件时,该控件将进入catch块.



When I try to run this control is going inside catch block.

推荐答案

Hmm,我自己尚未使用Xerxes-C库,但是-假设您正在使用此类-不是第三个参数应该是字符串缓冲区,将接收结果字符串?您正在传递一个int,甚至没有一个指针.我不知道这怎么编译?此外,第4个参数应该保留作为第三个参数传递的字符串缓冲区的大小.但是,您尚未初始化该值,str可能包含任何值,并且由于该值不明智,该函数可能正在抛出.

我建议您阅读API文档并传递正确的类型和类型的参数.
Hmm, I haven''t worked with the Xerxes-C library myself, but - assuming you are working with this class - isn''t the third parameter supposed to be the string buffer that is to receive the resulting string? You''re passing an int instead, not even a pointer. I wonder how does this even compile? Moreover, the 4th parameter is supposed to hold the size of the string buffer passed as the third parameter. You did not initialize that value though, str may hold any value, and the function may be throwing because the value is insensible.

I suggest you read the API documentation and pass the right kind and types of parameters.


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

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