I am trying to load the contents of the file saved on the dux into a string. File. The CS code, which is created in VisualStudio, I think it has been saved in UTF-8 coding. I am doing this:
FILE * fConnect = _wfopen (connectFilePath, _T ("r, ccs = UTF-8")); If (! FConnect) returns; Fseek (fConnect, 0, SEEK_END); Lisize = ftell (fConnect); Rewind (fConnect); LPTSTR lpContent = (LPTSTR) Molec (sized (TCHAR) * LC + 1); Fred (LP content, Size (TCHAR), LCs, Fconnect);
But the result is very strange - the first part (the string is half the content of the CS file), then weird symbols like 췍 췍췍 췍췍 췍췍 췍췍 췍췍 췍췍 췍췍 췍췍 췍췍 췍췍 appear. So I think I read the content wrongly. But how to do it properly? Thanks a lot and I want to hear!
Feetel (), fseek (), and Fread () work on all bytes, on letters No. In a Unicode environment, TCHAR is at least 2 bytes, so you are allocating and reading as much as you need to be twice as much memory as possible.
I've never seen fopen () or _wfopen () "ccs" attribute You should use "RB" as a reading mode, raw byte should be read in memory and once you have all available, i.e.:
FILE * fConnect = _wfopen ( ConnectFilePath, _T) ("rb")); If (! FConnect) returns; Fseek (fConnect, 0, SEEK_END); Lisize = ftell (fConnect); Rewind (fConnect); LPBET LP concentant = (LPBYTE) Molec (LC); Fred (LP content, 1, lcci, fconnect); Fclose (lpContent); ..decod lpContent as needed ... Free (lpContent);
Comments
Post a Comment