Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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:

C++
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
}


When I try to run this control is going inside catch block.
Posted
Updated 30-Aug-11 2:42am
v3
Comments
Prerak Patel 30-Aug-11 3:25am    
Share some code.
Stefan_Lang 30-Aug-11 4:49am    
We cannot possibly help you if you do not at the very least post the code that you tried out and that doesn't work. Also, "it fails" is less than helpful regarding your problem: What fails? In what way? Is it the compiler, the linker or runtime system that fails, or something else? What kind of error message or other piece of information do you get that tells you that something is wrong in the first place?

If you want us to put time and effort into finding an answer to your problem you should describe it as concisely as possible and provide all the required information around it, so we don't have to do guessing games as to what you might have been doing or not.
Marc A. Brown 30-Aug-11 10:03am    
You need to provide information about what exception is being thrown.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900