|
I googled on this topic. I got programming example. But I want theoretical topic or at least one line which shows difference between Unicode and Multibye.
|
|
|
|
|
Multibyte, or wide character, refers to the size of the datatype in memory, not how each value is defined. Unicode, however, is a character set that provides that definition.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
|
This is OK. But it doesn't show difference between Unicode and Multi-byte char.
|
|
|
|
|
Character sets descended from ASCII that are described in the "A Historical Perspective" section are multi-byte.
|
|
|
|
|
Lots of detail about this can be found in this white paper[^].
The best things in life are not things.
|
|
|
|
|
Unicode is a vast specification covering many things. Encluding serveral representations of some very broad (many natural languages) character sets.
There are also associated encodings for those character sets.
Some encodings have a fixed size and some are variable.
A variable size encoding has some byte sequences which represent specific characters and other byte sequences which are used as flags to indicate that additional bytes are needed to determine the actual character.
A multi-byte character set might either mean a fixed size representation of a character set but normally means a variable sized encoding which started with a single byte for the initial encoding. UTF8 is a variable sized encoding and can thus also be considered a multibyte character set.
For coverage of this specific point see the following
http://en.wikipedia.org/wiki/Multi-byte_character_set#Unicode_variable-width_encodings[^]
|
|
|
|
|
I have to develop an application that captures a portion of the desktop every 30 seconds, after viewing the captured image in the window of application, should find (and then highlight) which regions of the new image have changed compared to the previous image.
Ok, so:
HDC memDC;
memDC = CreateCompatibleDC( GetDC(hWnd) );
WM_TIMER:
InvalidateRect(...)
WM_PAINT:
hdc = BeginPaint(...);
screenDC = GetDC(0);
hBmp = CreateCompatibleBitmap(hdc, nWidth, nHeight );
hPrevBmp = SelectObject(memDC,hBmp);
BitBlt(memDC, ..., screenDC, ...);
BitBlt(hdc, ..., memDC, ...);
How can i compare the two image?
|
|
|
|
|
Member 2965471 wrote: How can i compare the two image?
Read here.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I've only understand i've to perform a XORing operation between the two image, but how can i do that? and then how can i highlight rectangular region modified? using GetPixel?
|
|
|
|
|
Hi all,
I am trying to find floppy drive in logical drives.
I am using GetDriveType() function, but it is returning DRIVE_REMOVABLE which for both flash drives and floppy drives.
How can i find this??
Thanks in advance
|
|
|
|
|
How To Getting Floppy Drive Type Information->[^]
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
VCProgrammer wrote: How can i find this??
How about something like:
bool isFloppyDevice( LPCTSTR lpszDevice )
{
TCHAR szBuffer[MAX_PATH];
bool bIsFloppy = false;
if (QueryDosDevice(lpszDevice, szBuffer, MAX_PATH) > 0)
bIsFloppy = (_tcsstr(_T("device\\floppy"), szBuffer) != NULL);
return bIsFloppy;
} A slightly longer way, although I cannot test it, might be:
bool isFloppyDevice( void )
{
bool bIsFloppy = false;
HANDLE hDevice = CreateFile(_T("\\\\.\\A:"),
0,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hDevice != INVALID_HANDLE_VALUE)
{
DISK_GEOMETRY dg;
DWORD dwBytesReturned;
bIsFloppy = (DeviceIoControl(hDevice,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
&dg,
sizeof(dg),
&dwBytesReturned,
NULL) != FALSE);
CloseHandle(hDevice);
}
return bIsFloppy;
}
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi:
I have a socket client running which has a char array of size 512 mentioned. I have a loop to receive the message from the server, when the loop exits I am getting the following error.
I also confirmed that the message I am receiving from the server is less than 200 characters in length.
Environment:
Windows 64bit.
VS 2010
Run-Time check failure #2 - Stack around the variable 'recMessage' was corrupted.
int STRLEN = 512;
char recMessage[STRLEN] = "0";
ClientSocket sockClient;
sockClient.ConnectToServer( ipAddress.c_str(), port );
sockClient.SendData("L|100=some_value;101=some_value\n");
sockClient.RecvData( recMessage, STRLEN );
int counter = 0
while(counter <= 10){
sockClient.RecvData( recMessage, STRLEN );
cout << recMessage << endl;
counter++;
}
memset(recMessage,0,sizeof(char)*STRLEN);
sockClient.CloseConnection();
</pre>
|
|
|
|
|
The code as you've posted looks okay.
It's probably something going wrong in the methods of the ClientSocket class.
|
|
|
|
|
I hope you already know this, but this:
int STRLEN = 512;
char recMessage[STRLEN] = "0";
Will not compile in C++.
This leads to the next question:
If you say the program crashes in runtime, how is the array really declared?
|
|
|
|
|
Actually it works, even though the initialization is quite probably not what it is intended to be. The string "0" is a char array of length 2, containing the 2 characters '0' and '\0' (==char(0) ).
But then, the contents of this array are irrelevant as it's filled by RecvData() before it ever gets read.
I therefore suggest to just skip the initialization.
|
|
|
|
|
I'm not talking about the initialization part - I'm aware that it's quite legal.
The problem is that array declarations in C++ need constant size expressions. And this:
char recMessage[STRLEN]
is by all means an array declaration, where STRLEN is not a constant.
|
|
|
|
|
Ah, sry, I missed your point then.
I'm always a bit suspicious about forms of array initialization, so I automatically assumed that was what you're at.
Sure, the code is missing a const there, which makes me wonder if it has been compiled as C-code, rather than C++? But I wonder if it's even possible to compile the invocation of a socket object as C-code - I don't think it is...
|
|
|
|
|
It should still compile since the value of STRLEN is known at compile time.
|
|
|
|
|
Well, there's "should" and then there's the compiler itself.
int STRLEN = 512;
char recMessage[STRLEN] = "0";
1>c:\users\otoolec\documents\visual studio 2008\projects\test2\test2\test2.cpp(14) : error C2057: expected constant expression
1>c:\users\otoolec\documents\visual studio 2008\projects\test2\test2\test2.cpp(14) : error C2466: cannot allocate an array of constant size 0
Now add "const" and the following does compile:
const int STRLEN = 512;
char recMessage[STRLEN] = "0";
|
|
|
|
|
In fact it should not, as it would require the compiler to analyze the semantics of the code in order to make sure that the variable STRLEN is not being changed. Even though this could be done in an easy example like this, the syntax is just as wrong as a missed '; '. Have you ever seen a compiler insert a missing ';' for you, no matter how obvious the fix?
|
|
|
|
|
You're right. It would unnecessarily complicate things.
|
|
|
|
|
|
I'm not that familiar with the ClientSocket class but I have a few observations / questions.
1) Clearly you expect "recMessage" to be a null terminated string (you "cout" it)
2) Who puts the NULL character at the end of each message?
3) Your buffer is "STRLEN" characters long (assuming you fix the declaration), you tell RecvData to read "STRLEN" characters. Who accounts for the NULL? Either the buffer needs to be one character bigger or the RecvData should be for one character smaller.
4) there is nothing to indicate the length of the received message in that API so how do you know or verified that all messages are < 200 characters as you stated in another reply.
5) the memset at the end of the routine does nothing useful. While it looks OK, are you sure that statement is not causing the problem.
6) other folks have commented on the declaration "char recMessage[STRLEN]" where STRLEN is not a #define constant but a variable. I suspect this is not what is used in the actual compiled code.
|
|
|
|