|
char strUTF8[] = { unsigned char(0xEF), unsigned char(0xBB), unsigned char(0xBF),'\0' };
char str[4];
sprintf(str,"%c%c",255,254);
CStdioFile m_OutPutFile;
m_OutPutFile.Open(_T("C:\\ANSI.txt"),CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
m_OutPutFile.Close();
m_OutPutFile.Open(_T("C:\\UTF8.txt"),CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
m_OutPutFile.Write(strUTF8,strlen(strUTF8)*sizeof(char));
m_OutPutFile.Close();
m_OutPutFile.Open(_T("C:\\Unicode.txt"),CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
m_OutPutFile.Write(str,strlen(str)*sizeof(char));
m_OutPutFile.Close();
Ok run this code in any console application and check in which encoding format these files are saved.
I believe in LOVE AT FIRST SIGHT...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
Shilpi Boosar wrote: Ok run this code in any console application
Why?
Shilpi Boosar wrote: and check in which encoding format these files are saved.
And exactly what universally accepted standard are you going to use to do that?
|
|
|
|
|
Joel has an easy articlle[^] on basics of Unicode. I'd start with reading that.
|
|
|
|
|
I have a Handle to the Rich Edit Control of Wordpad application in my Keypad application. I want to directly access the Internal Data Structure for this Rich Edit Control without using Windows Messages .
I do not want to use any of the SendMessage PostMessage APIs or Windows Messaging as this exposes my typed data to keyloggers. How can I write directly to the Internal Buffer of Rich Edit Control ?
Kamal Jagesia
|
|
|
|
|
To my knowledge, no windows control, not just richedit32 but buttons, statics and everything can only be interacted with through the windows message pump.
Keyboard loggers generally work by installing keyboard hooks, which wont pick up these interactions, however it is possible (as Spy++ proves) to intercept the message pump however there would be so much data to sift through for the attacker that it wouldn't be a practical attack.
|
|
|
|
|
I'm not sure exactly what you are trying to do but you may wish to create your own class based on the
CRichEdit[^] class. You may then be able to gain access to some of the internals of the class.
I must get a clever new signature for 2011.
|
|
|
|
|
hello
please can any one help me. how to make point to Rect .
for example i had two point..
cpoint p1,p2;
now p1 has (x1,y1);
p2 is (x2,y2);
how to make it into Rect .....
thanking you
sarfaraz
|
|
|
|
|
CRect has a constructor which accepts two points: the top-left corner and the bottom-right corner, please check the MSDN documentation.
|
|
|
|
|
|
Hi dear..
First of all you have to take one CRect..
CRect rectangle;
rectangle.left = p1.x;
rectangle.top = p1.y;
rectangle.right = p2.x;
rectangle.bottom = p2.y;
|
|
|
|
|
1. Is it legal to use
#include<atlstr.h>
in a win32 native Windows Application.
2. Does using atlstr.h in Win32 Native Windows Application causes any kind of error.
<br />
Source Found on Internet:<br />
Starting VS 2003, you can use CString in non-MFC applications by including header atlstr.h:
Some Day I Will Prove MySelf :: GOLD
|
|
|
|
|
Yes you can use it.
1) If you create an application than one option for ATL i.e. "Add common header files for ATL" is displayed.If you select these than it automatically add this header for you.
or
2) You can use basic_string of STL, std::string, std::wstring as per your requirement.
I believe in LOVE AT FIRST SIGHT...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
do std::wstring has trim function as CString have.
(Trim, LTrim, RTrim )
Some Day I Will Prove MySelf :: GOLD
|
|
|
|
|
No there is no built in functionality for trim in basic_string but you can make a function of it. Search on Google, you will get the better result
First link of google that have solution is :
Click here ->
I believe in LOVE AT FIRST SIGHT...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
thanx nice
Some Day I Will Prove MySelf :: GOLD
|
|
|
|
|
WC
I believe in LOVE AT FIRST SIGHT...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
Indeed you may use CString in a Win32 application. However std::string might be a valid alternative.
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]
|
|
|
|
|
To begin, I'm enrolled a some programming classes at the my university, so I'm getting my C++ feet wet through experimentation. The following code generates a heap corruption error everytime I launch it.
#include<iostream>
using namespace std;
struct IntArray
{
int Iarray[0];
};
void main()
{
char end;
short num = 20;
IntArray* A = (IntArray*)new int(sizeof num);
for ( short i = 0 ; i < 10 ; ++i )
{
A->Iarray[i] = ( i * 10 );
}
for ( short j = 0 ; j < 10 ; ++j )
{
cout << A->Iarray[j]," ";
}
cin >> end;
delete A;
return;
}
This is the error that it generates before the program even starts to run:
"Windows has triggered a breakpoint in My Arrays.exe.
This may be due to a corruption of the heap, which indicates a bug in My Arrays.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while My Arrays2.exe has focus.
The output window may have more diagnostic information."
I following the exact procedures found in the MSDN article:
http://msdn.microsoft.com/en-us/library/0scy7z2d(VS.80).aspx
I'm trying to build array methods that I can understand.
Any idea on where I screwed this up will be helpful to the learning process.
|
|
|
|
|
Foothill wrote: IntArray* A = (IntArray*)new int(sizeof num);
Not sure why you are allocating memory for this from the heap. Since only one A is being used, just use:
IntArray A;
Foothill wrote: int Iarray[0];
This will only hold one int , not 10.
Foothill wrote: cout << A->Iarray[j]," ";
Perhaps you meant:
cout << A->Iarray[j] << " ";
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I'm trying to dynamically resize arrays at runtime so that I can make a self-addaptable code to handle a variety of needs. This was just the initial attempt. As far as 'why from the heap?', the MSDS example was the first destination following my first attempts at this so if there are other ways, I would love to know about them. BTW, thanks for the syntax correction help, switching my brain from Visual Basic to C++ isn't as easy as I thought it would be.
|
|
|
|
|
Foothill wrote: I'm trying to dynamically resize arrays at runtime
With the CRT, there was the realloc() function. Otherwise, it's not much more difficult, you just have to do more yourself. For example:
int *x = new int[3];
x[0] = 2;
x[1] = 4;
x[2] = 6;
int *y = new int[5];
memcpy(y, x, 3 * sizeof(int));
y[3] = 8;
y[4] = 10;
delete [] x;
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Perfect Answer 5 .
I love to read your answer because you explain the things perfectly
I believe in LOVE AT FIRST SIGHT...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
Foothill wrote: I following the exact procedures found in the MSDN article:
http://msdn.microsoft.com/en-us/library/0scy7z2d(VS.80).aspx
Read it once, it is an example of "Compiler Error C2229".
The way David give is correct or you may use malloc and realloc.
I believe in LOVE AT FIRST SIGHT...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
Everyting but this line:
IntArray* A = (IntArray*)new int(sizeof num);
looks to be ok. (Well, you might want to use num instead of 10 in your loops)
int *i = new int(n);
will allocate space for one int, and initialize it with the value of n. Your case is like this, where n = sizeof num which is the number of bytes in a short, typically 2. This is not much of an array, even though you may access it as a single element array.
On the other hand
int *a = new int[n];
will allocate space for n int s. If you change your line to
IntArray* A = (IntArray*)new int[num];
your code will be alright.
|
|
|
|
|
Foothill wrote: #include
is missing the filename to be included, e. g.
#include <io.h>
Foothill wrote: int Iarray[0];
This technically declares an array of 0 integers. However, I believe for some obscure reasons compilers are obliged to always allocate at least one element for an array, so in the end your struct will contain exactly one int. What you probably meant is (also see below):
int *Iarray;
Foothill wrote: IntArray* A = (IntArray*)new int(sizeof num);
As has been pointed out, this allocates memory for just one int and initializes it with 2. Also you are blindly casting the result of the allocation to IntArray* . You cannot equate the struct you defined with the array you defined within that struct even though the compiler will permit this.
First, sizeof delivers the size of the memory required to hold a variable of a particular type, in this case short . If you want the value that a variable holds, just write its name, num , instead.
Second, new takes several parameters, but it's syntax is special:
new int allocates memory for one variable of type int, and returns a pointer to its address.
new int(5) allocates memory for one variable of type int, and initializes it with the value 5, then returns a pointer to its address.
new int[5] allocates memory for a block of five variables of type int, and returns a pointer to the start of that block, holding the first element.
In all these cases, the return type is int* . So you could for instance assign any of the above expressions to A->Iarray , without the need for a type cast. The following line for example would allocate a block of 20 integers and assign its address to A->Iarray :
A->Iarray = new int[num];
However, that would assume you have a variable A of type struct IntArray, which you could dynamically allocate with
IntArray *A = new IntArray;
Of course, you could just as well define A as a local variable like this:
IntArray A;
You would need to write A.Iarray instead of A->Iarray then of course, since A is no longer declared as a pointer.
Foothill wrote: for ( short i = 0 ; i < 10 ; ++i )
You should use the correct limit for the loop, i. e. num instead of 10 , assuming that you indeed correctly allocated an array of num elements.
Foothill wrote: cout << A->Iarray[j]," ";
The '<< ' operator should be used for each element that you want to print out individually, until the end of the operation; writing cout << "hello " << "world"; will give you the same result as cout << "hello "; cout << "world"; , but in the first case you need the second << ! What you probably wanted to write was
cout << A->Iarray[j] << ", ";
Foothill wrote: delete A;
With the incorrect use of new above, this line is correct, and nothing will happen. But if you correct your allocation statement as indicated above, you need to specifically tell the compiler that it is an array that you want to delete, not an individual object. You do this by using delete [] instead of delete :
delete [] A->Iarray;
Sorry to repeat some of the corrections already given, but I thought it won't hurt to put everything in one place.
|
|
|
|