|
You can use MultiByteToWideChar may be somethng like this
CString str;
wchar_t* wch
MultiByteToWideChar(CP_ACP,0,str,strlen(str),wch,strlen(str),NULL,NULL)
Don't forget to allocate memory to this wchar variable
then typecast this wchar to unsigned short*
FillSafeArray((unsigned short*)wch ,....)
I think this will help u out !!!
|
|
|
|
|
typecast it to const unsigned short* .....
FillSafeArray((const unsigned short*).....
|
|
|
|
|
hi all
can anybody tell me is whats the difference between UTF-8 and multibyte.
and from where i can find more information on the same?
Thanx in advance.
|
|
|
|
|
Google for "UTF-8 multibyte" and you will get many hits. Try Wikipedia first.
|
|
|
|
|
UTF-8 is a Unicode encoding scheme.
Multibyte is a common name for a number of legacy encodings that typically store strings in char arrays (in C) as opposed to wchar_t arrays.
|
|
|
|
|
Nemanja Trifunovic wrote: Multibyte is a common name for a number of legacy encodings that typically store strings in char arrays
Thus in the sense of your definition UTF-8 is a multibyte-format.
UTF-16 (not that someone in his right mind would use that) isn't.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
jhwurmbach wrote: UTF-8 is a multibyte-format.
It is in a sense that is usually stored in char arrays and is a variable length encoding, but as I said the term "multibyte" is usually used for various legacy ASCII extensions such as SHIFT_JIS. UTF-8 is really a Unicode encoding.
jhwurmbach wrote: UTF-16 (not that someone in his right mind would use that) isn't.
You probably mean UTF-32.
|
|
|
|
|
Nemanja Trifunovic wrote: jhwurmbach wrote:
UTF-16 (not that someone in his right mind would use that) isn't.
You probably mean UTF-32.
I meant UTF-8 in the original meaning. According to the link[^]given in the posting below, UTF-16 is fixed 16-bit (and seems to be what the Windows-designers had in mind when they added the UNICODE-Functions taking wchar_t)
It seem as if standard bodies have tampered with UTF-16.
UTF-8 uses bytes, but it leaves the fixed relationship one code number <-> one character (which UTF-16) reatined.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
jhwurmbach wrote: According to the link[^]given in the posting below, UTF-16 is fixed 16-bit
Don't know about the link, but UTF-16 is definitelly not fixed 16-bit per character. There are surrogate pairs[^] that cover the space above 16 bits.
On the other hand, with UTF-32, each code point is encoded with a 32-bit number, and it is the only fix-length Unicode encoding schema.
|
|
|
|
|
|
Hi
I want to Read the JPEG file in the CFile or CStdioFile format.
I used to Write and read ".doc",".xt" file format by
CStdioFile file1;
file1.m_pStream=fopen("d:/newfile1.doc","a+");
file1.WriteString(L"hai");
file1.Close();
now i want to Read and Write the JPEG formated file.Some of them said read file in Binary format, but i dont know how to read in binary format.
Give your suggestion to Read and Writeing of jpeg file format
regards
shakumar
shakumar
|
|
|
|
|
I think you must read stream fundamentals.
fstream fs;
fs.open("file.txt",ios::bin); // not sure about bin or binary.
Search in C++ books, msdn does not have good documentation about streams.
|| ART OF LIVING ||
|
|
|
|
|
Please refer here[^].
Regards,
Paresh.
|
|
|
|
|
shakumar_22 wrote: file1.m_pStream=fopen("d:/newfile1.doc","a+");
Why use this? there is an open function for CStdioFile and CFile.
file1.Open("d:/newfile1.doc",CFile::modeRead|CFile::modeWrite);
There are some other flags also for opening.
you can use the same for opening JPEG files. But what you gonne do by reading row JPEG data?
|
|
|
|
|
I want to send JPEG file through socket and write there in the receiving system as JPEG file.
for that purpose only i reading the jpeg file.
if any other way also suggest me to transfer the JPEG FILE through Socket from one system to onther
shakumar
|
|
|
|
|
shakumar_22 wrote: if any other way also suggest me to transfer the JPEG FILE through Socket from one system to onther
Your idea is not bad. you dont have to do any special handling for transfering JPEG file. Follow the same steps you followed for doc and other files.
|
|
|
|
|
You havent understand and I guess read the documentation of the CStdioFile class. Read this first and do your homeworks at home.
Greetings from Germany
|
|
|
|
|
shakumar_22 wrote: Some of them said read file in Binary format, but i dont know how to read in binary format.
See here for the difference between binary and text files. That said, consult MSDN for the distinction between CFile and CStdioFile .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have successfully created a winform user control that i use on a webform by exposing it as an ActiveX control using the <object> tags.
Is there a way for me to access the objects public methods/properties from the ASP.NET code behind files when i post the aspx page back to the server?
Sinoop Sundar, Colossal Technologies
|
|
|
|
|
Hello Friends,
Does anybody know a function to monitor the single file and not the folder. I know there is a function named FindFirstChangeNotification() but that monitores the Folder or Folder tree I want to Monitor the Single File :->. Becoz When I am using the above function I am facing lots of probelms that i have posted earlier. (see Just below post)
|
|
|
|
|
hi,
you can take a look to the native API function ZwQueryDirectoryFile that are capable to help you in your research.
|
|
|
|
|
Hello Friends,
I have a little problem.I m working on a project.In this project we have a tree view wich shows the files. When user clicks on the file a new process created ( Say Notepad, It may be any Software, MSWord Too) and a File user has clicked opened in it. I have to moniter the that file.(i.e. When user save the changes he has made has to upload the file somewhere) for that I have created the thread when the process is created and in the Thread Procedure I am Monitoring the file using FindFirstChangeNotification() function. It works fine when the user has created a single process(i.e. Has open the single file) . But the problem occures when user has created more than on file. Becoz each time user creates the file a thread is created and it does the same thing (i.e. Monitor the perticular directory, in my case it is Temp)which another thread from earlier process is doing. So all the things is happening as many times the user has opened the process.
For Example. I am displayig the MessageBox when user save the file. if user has created 3 process and even if it saves the single file 3 MessageBox displyes to him.(and all the other task is also happend many times rather than one)
Below are some of the code that i am using.
<br />
if (CreateProcess(0, str, 0, 0, 0, 0, 0, 0, &startupinfo, &ProcessInformation))<br />
{<br />
DWORD lpExitCode; <br />
HANDLE hMonitorThread=CreateThread(0,0,(LPTHREAD_START_ROUTINE)MyThreadProc,NULL,0,0);<br />
GetExitCodeThread(hMonitorThread,&lpExitCode);<br />
HANDLE handles[2];<br />
handles[0] = (HANDLE)pQueueData->retrycount;<br />
handles[1] = ProcessInformation.hProcess;
int res=WaitForMultipleObjects(2, handles, FALSE, INFINITE);<br />
if (res==(WAIT_OBJECT_0+1) || res==(WAIT_ABANDONED_0+1))<br />
{<br />
if(TerminateThread(hMonitorThread,lpExitCode))
<br />
CloseHandle(ProcessInformation.hProcess);<br />
Sleep(500);<br />
...<br />
...<br />
}<br />
void MyThreadProc(void)<br />
{<br />
while(TRUE)<br />
{<br />
<br />
hFile = FindFirstChangeNotification(szTempDir,TRUE,FILE_NOTIFY_CHANGE_SIZE);<br />
dwWaitOver = WaitForSingleObject(hFile,INFINITE);<br />
if(!dwWaitOver)<br />
{<br />
if(::MessageBox(NULL,"You Have just Saved the File \n Want to make Changes on the Server", "MainFrame",MB_YESNO|MB_SYSTEMMODAL|MB_ICONINFORMATION ) == IDYES)<br />
{<br />
AfxGetApp()->m_pMainWnd->PostMessage(WM_APP, reinterpret_cast<WPARAM>(MypQueueData),(LPARAM)DoNotDelete)<br />
<br />
}<br />
}<br />
FindNextChangeNotification(hFile);<br />
<br />
}<br />
<br />
Now i dont know what to do. Is there any function that monitores the perticular file change rather than a folder. or is there any way I can improve the codeing and solve the problem. I have tried to Create a single thread to monitor for all process but it has its own problem
So if U have any solution please tell me..
|
|
|
|
|
may be you can try the ReadDirectoryChangesW() function. cause if you use that function, you can find which file actually changed. so if it is not the file you needed, you can ignore it and continue watching..
|
|
|
|
|
I have tryed to use the function you have told me to. But i failed to use this. might be becoz i am novice programmer in VC++.
I dont know what error come but I fail to retrive the File name.
void ReadFileChange(void)<br />
{ <br />
OutputDebugString(" ReadFileChange() ");<br />
char* path = "C:\\DOCUME~1\\gaurang\\LOCALS~1\\Temp";<br />
BOOL Success;<br />
DWORD dwByteReturned;<br />
FILE_NOTIFY_INFORMATION Buffer;<br />
<br />
int size = sizeof(FILE_NOTIFY_INFORMATION);<br />
<br />
HANDLE hDir = CreateFile(path,FILE_LIST_DIRECTORY,<br />
FILE_SHARE_READ|FILE_SHARE_DELETE, <br />
NULL,OPEN_EXISTING, <br />
FILE_FLAG_BACKUP_SEMANTICS,NULL<br />
); <br />
<br />
Success = ReadDirectoryChangesW(hDir,&Buffer,64,FALSE,FILE_NOTIFY_CHANGE_SIZE,<br />
&dwByteReturned,NULL,NULL);<br />
if(!Success)<br />
OutputDebugString("Read Directory Change Failed ") ; <br />
OutputDebugStringW(Buffer.FileName);<br />
<br />
}
I dont know what to use in as the size in Buffersize parameter. so I just took 64.
|
|
|
|
|
Gaurang Shah 033 wrote: I dont know what to use in as the size in Buffersize parameter. so I just took 64.
some pblms in the code. i have corrected it. Check it. the pBuffer->FileName will be having the file name.
char* path = "C:\\DOCUME~1\\gaurang\\LOCALS~1\\Temp";<br />
BOOL Success;<br />
DWORD dwByteReturned;<br />
int size = sizeof(FILE_NOTIFY_INFORMATION) + (MAX_PATH * 2);<br />
FILE_NOTIFY_INFORMATION* pBuffer = (FILE_NOTIFY_INFORMATION*) new BYTE[ size ] ;<br />
HANDLE hDir =CreateFile ( path,<br />
GENERIC_READ,<br />
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,<br />
NULL,<br />
OPEN_EXISTING,<br />
FILE_FLAG_BACKUP_SEMANTICS,<br />
NULL<br />
);<br />
Success = ReadDirectoryChangesW( hDir,pBuffer,size,FALSE,FILE_NOTIFY_CHANGE_FILE_NAME, &dwByteReturned,NULL,NULL);<br />
delete pBuffer;
|
|
|
|
|