|
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?
|
|
|
|
|
You could make the lengthy operation run in a separate thread within the activex control.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
(don't know if this should be in the design forum, anyway, I'm coding in C++)
I have a factory that will eventually create many, many different objects.
usually, I have something like (pseudo-c++-ish):
#include "type1Class.h"
#include "type2Class.h"
#include "type3Class.h"
#include "type4Class.h"
static BaseClass* MyClass::Builder(ObjectType type)
{
switch (type)
{
case type1: return new Type1Class;
case type2: return new Type2Class;
case type3: return new Type3Class;
case type4: return new Type4Class;
}
}
Now, for a small number of classes this is manageable; but for a large number of classes it creates a large number
of includes and a huge switch.
Is there another pattern or methodology to clean that potential mess ?
I known I can put all typeXClass.h includes in a separate include file and have that one included; that will reduce the number of lines; any other tips hints ?
Thanks.
--------- edit------
Thanks to Stuart and Cédric; I will have a look at their solution first thing after coffee next monday!
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: Is there another pattern or methodology to clean that potential mess ?
I dont think so, but depends on your definition of large I guess - in which case you might want to partition your classes by some abstract case and have multiple factories.. you could also consider 'pre-allocating' the objects to trade off against the lookup time (if thats an issue) - we have an implementation in a realtime message-switch that only has 30-40 classes, one for each message, but we pre-allocate them in the factory before we start accepting connections
'g'
|
|
|
|
|
How would I do it...well, I'd make use of a std::map and some Boost magic:
struct BaseClass {};
struct C1 : public BaseClass {};
struct C2 : public BaseClass {};
struct C3 : public BaseClass {};
typedef BaseClass* BaseClassPtr;
BaseClassPtr Make(std::string const& type)
{
using namespace boost::lambda;
typedef boost::function<BaseClassPtr()> Constructor;
static const std::map<std::string, boost::function<BaseClassPtr()> > factoryMap =
boost::assign::map_list_of("C1", Constructor(new_ptr<C1>()))
("C2", Constructor(new_ptr<C2>()))
("C3", Constructor(new_ptr<C3>()));
const std::map<std::string, boost::function<BaseClassPtr()> >::const_iterator constructor = factoryMap.find(type);
return (constructor != factoryMap.end())?constructor->second():0;
}
Create a map that relates your factory key to a suitable object pointer constructor function object - here I've used Boost.Lambda's object construction functions.
When you look up a type key, you either find it (in which case you invoke the constructor) or not (in which case I return a null pointer).
Adding a new type only requires you to add one line to the map initialiser.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hooooo!!! sexy!
Thanks.
This signature was proudly tested on animals.
|
|
|
|
|
I use an approach similar to the one from Stuart's but by using some little tricks, you can automate the process of registration.
So, the base principle is that the factory is aa wrapper around a map with the class identifier (type) as key and a function to create the object as value. So, this way your factory remains independant of your different objects.
Then, you have a public function on your factory to add a new creation function to the map:
typedef BaseClass* CreateFunc ();
....
void RegisterCreator(ObjectType type, CreateFunc* pFunc);
Now the "smart" trick is to let the classes register themselves through static initialization. At the top of the cpp file of your class, you add code similar to this:
int RegisterType1Class()
{
CObjectFactory::GetInstance().RegisterCreator(Type1, Type1Class::CreateObject);
return 0;
}
static int Temp = RegisterType1Class();
The Type1Class::CreateObjec is a static function of your class which simply creates a new instance of the class.
This mechanism allows you to automatically register objects to your factory through static initialization. Your factory has to be a singleton also.
Using this technique, your factory remains completely independant from all your different specific objects (it only has to know the base class), and you get rid of the big ugly switch.
|
|
|
|