Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

i have doubt in CStdio File i have text in file i.e

REPTVW_PRJ_ID_BID_REPORT_OPEN_IN_WORD="Open in Word™"

its reading everyhting fine expect ™

its raeding like REPTVW_PRJ_ID_BID_REPORT_OPEN_IN_WORD="Open in Word"


trade mark is not reading from the file

what might be the problem please let me know
Posted
Updated 20-May-15 20:24pm
v2
Comments
Jochen Arndt 21-May-15 3:00am    
What is the encoding of the text file?
Especially what hex code is used for the TM character?
You can check this with a hex editor or by reading the file in binary mode into a buffer.
CStdioFile supports only ANSI files. See also the tip http://www.codeproject.com/Tips/465194/Read-and-Write-Text-Files-in-Unicode-through-CStdi
[no name] 21-May-15 3:09am    
thi is ansi file not uniocde file .... but in uniocode version
[no name] 21-May-15 3:11am    
tried but same output
Richard MacCutchan 21-May-15 3:56am    
Use your debugger to see what is getting stored in memory for that character. It is most likely that your code is reading it, but your program is not displaying it correctly.
[no name] 21-May-15 4:06am    
if (!fileIn.Open(_T("D:\\CVEnglish.lex"), CFile::modeNoTruncate | CFile::modeRead, &ex))
{
ex.ReportError();
return ;
}
// CStdioFile fileIn(_T("D:\\CVEnglish.lex"),CFile::modeRead);

CString sRead;
fileIn.ReadString(sRead);
fileIn.Close();

1 solution

I have tested it and there is only a problem with Unicode builds.

The reason is that ReadString uses fgetws which calls mbtowc which uses the current locale for character conversion. When the locale is not set by your program it defaults to the C locale which only supports ASCII. So you must set the locale once upon program start:
setlocale(LC_ALL, "English");

See also the MSDN setlocale[^] page.

[EDIT]
To set the locale to the ANSI code page actually used by Windows use:
setlocale(LC_ALL, ".ACP");
 
Share this answer
 
v2
Comments
[no name] 21-May-15 5:33am    
it will affect for other languages ?
Jochen Arndt 21-May-15 5:38am    
It will affect how specific functions handle locale settings (see https://msdn.microsoft.com/en-us/library/wyzd2bce.aspx for the functions).
You may call setlocale again if you need other settings. I will update my answer with a general setting according to the used Windows code page.
[no name] 21-May-15 5:40am    
yes please let me know ?
Jochen Arndt 21-May-15 5:45am    
You should use the Reply button right of a comment to answer. Then that poster will get a mail notification.

I don't know which code page is used in India (or on your system). If that does not contain the TM symbol, using ".ACP" might not work. But using "English" with your file works.
[no name] 21-May-15 5:53am    
ok then for other language japanase it will affect ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900