|
Convert unicode text into byte stream, then convert that byte stream into hex.
|
|
|
|
|
Thank you Manish Rastogi.
Did you mean char array by "byte stream"?
I tried to convert my string to char array and then convert to hex. Still getting wrong results
Can you give me an example, please?
|
|
|
|
|
msn92 wrote: I tried to convert my string to char array and then convert to hex. Still getting wrong results Smile
Can you give me an example, please?
Could you please post your code?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Of course!
CString UnicodeToHex(CString unicode){
char* unicode_((char*)unicode.GetString());
CString hex=L"";
for (int i=0;i<unicode.GetLength();i++)
{
hex.Append(L"%");
hex.AppendFormat(L"%x",unicode_[i]);
}
return hex;
}
|
|
|
|
|
msn92 wrote: char* unicode_((char*)unicode.GetString());
unicode_ is serving no purpose in this code snippet.
With input of %F1%E8%EC%E2%EE%EB , what are you expecting the output to be?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
msn92 wrote: символ = %F1%E8%EC%E2%EE%EB
The above sentence is wrong. The hexadecimal representation of the UNICODE characters символ is
{ 0x0441, 0x0438, 0x043c, 0x0432, 0x043e, 0x043b} .
msn92 wrote: for (int i=0;i<unicode.GetLength();i++)
In the above statement, the index i should run for (unicode.GetLength() * 2) .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini, thank you for your reply.
I have a web form that I need to submit programmatically and data should be in unicode.
When I submit that web form using Firefox with the text символ , this is what Firefox is sending to the server:
%F1%E8%EC%E2%EE%EB
And I'm trying to send the same thing programmatically.
So if символ = %F1%E8%EC%E2%EE%EB is wrong, why Firefox is sending it like that?
Is it because of charset=WINDOWS-1251 in the source code of the web page:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=WINDOWS-1251" />
</head>
<body>
<form action="i.php" method="POST">
<input type="text" name="txt" />
<input type="submit" value="Submit" />
</form>
</body>
What should I do to convert to the same hex format Firefox is using?
Please let me know, if I'm not clear enough.
|
|
|
|
|
Ok, I figured it out.
It is because of the charset (windows-1251).
And to convert them to the hex format that firefox is using(windows-1251 charset), I had to replace each russian letter by hand with its hex equivalent in windows-1251 charset.
I know, it's not the best way, but I couldn't find better one:
Just in case, if someone needs it:
void Win1251ToHex(
CString &input,
CString &hex
)
{
hex=L"";
for (int i=0;i<input.GetLength();i++)
{
int ii=input[i];
if(ii>1024){
if((ii>1039)&&(ii<1104)){
BYTE x=0xC0;
x=x+(ii-1040);
hex.Append(L"%");
hex.AppendFormat(L"%x",x);
}else{
switch (ii)
{
case 8218:
{
hex.Append(L"%82");
break;
}
case 8222:
{
hex.Append(L"%84");
break;
}
case 8230:
{
hex.Append(L"%85");
break;
}
case 1038:
{
hex.Append(L"%A1");
break;
}
case 1118:
{
hex.Append(L"%A2");
break;
}
case 1025:
{
hex.Append(L"%A8");
break;
}
case 1105:
{
hex.Append(L"%B8");
break;
}
case 8470:
{
hex.Append(L"%B9");
break;
}
}
}
}else if(ii<127){
hex.Append(L"%");
hex.AppendFormat(L"%x",ascii[i]);
}
}
}
modified on Sunday, August 30, 2009 2:09 AM
|
|
|
|
|
Hi all,
I m using CeCreateProcess to create process,
CString CMDdata;
PROCESS_INFORMATION pi;
CeCreateProcess(L"Test.exe",T2CW((LPCTSTR)CMDdata),NULL,NULL,FALSE,0,NULL,NULL,NULL,&pi);
Here CMDdata have 70,507 characters ,when i debug my code after execution of this line control goes and not return to next line,and application becomes not responding or may crashing occur.
while if CMCData have less number of charcter than its working fine .please tell me the maximum value for this.
and if possible please explain me with any other example.
or any other way.
please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: Here CMDdata have 70,507 characters ,when i debug my code after execution of this line control goes and not return to next line,and application becomes not responding or may crashing occur.
70K+ characters as a command line argument?! Can't you let the application start and read this string from a file?! Not to mention you're doing mobile development and that you should use resources carefully.
"_$h@nky_" wrote: while if CMCData have less number of charcter than its working fine .please tell me the maximum value for this.
See What is the commandline length limit[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
According to google maximum command line legth for CreateProcess ,which is CeCreateProcess alternative for desktop machines is 32767 characters [^].I suppose this value is even smaller for the CE function.
Life is a stage and we are all actors!
|
|
|
|
|
I use ShellExecute() to show local html page.
My Q is:
how to hide toolbar of default IE?
Do you know if other functions can hide IE toolbar templately?
|
|
|
|
|
Just use IE COM (disable flag)
|
|
|
|
|
Fairly worthless suggestion, don't you think?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I want the message that send every time when user do something on dialog such as click on control button, input some character on edit control, select some row on listcontrol etc.
What the message that support this issue?
|
|
|
|
|
Max++ wrote: I want the message that send every time when user do something on dialog such as click on control button, input some character on edit control, select some row on listcontrol etc.
What the message that support this issue?
Sorry?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
When Draw windows framework send me WM_PAINT
When windows create framework send me WM_CREATE
When change windows size framework send me WM_SIZE
what about when "user do something on dialog such as click on control button, input some character on edit control, select some row on listcontrol etc.".
What the name of this windows message?
|
|
|
|
|
There are event handlers for every such control. Have you tried looking into the documentation of such controls? Have you searched for examples? Please do it. You might also buy a good book on MFC.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I don't want the Control Message but I want the Dialog message instead.
I need the message that send every time when user do something on all control on Dialog.
|
|
|
|
|
Max++ wrote: I need the message that send every time when user do something on all control on Dialog.
You can see them all with Spy++[^] or WinAPI documentation of your choice.
|
|
|
|
|
hello:
I have a problem,I write a IOCP DLL but there is something wrong with the memory, it call me first chance in xxxx... I worden where wrong it is. otherwise there is a problem with the delete it tell i delete a memory i do not have but i have no idear why the memory is changed.
if someone would like to help, i could give him my code. please send your e-mail to 315633820@qq.com.
think you for help.
|
|
|
|
|
As a first step I would run the program under the debugger and try to find out where the error occurs. this should give some idea of the general problem area from where you can narrow it down to the more specific point of failure. Adding some debug trace code might also be useful.
|
|
|
|
|
Hi:
First thank you for your help.I want to give you my code, but i do not find where can add it,could you give me your e-mail address.think you.
|
|
|
|
|
Please see my previous message. You need to try and discover where the program is failing, and then examine the code in that area. Use the DEBUG mode and breakpoint facility to narrow the problem down. It is no good sending the complete code to me as I have no idea what the program is trying to do.
|
|
|
|
|
Hi all!!
I am loading a swf file inside the ActiveX object in my dialog, but some operations inside the swf are lenghy and make my dialog not responsive, is there a way to make the Activex object run in an another thread?
|
|
|
|