Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi
I have wrote a VC++ project . in design mode for interface of program , I write Persian in caption field and I run the project , But in run mode the Texts is shown " ?????? "

How can I fix it?
Posted

Ever heard of Unicode and how it works?
Please see:
http://en.wikipedia.org/wiki/Unicode[^],
http://unicode.org/[^].

Unicode is not encoding. One thing you need to know is that on Windows memory representation of Unicode text is UTF-16LE. Please see:
http://www.unicode.org/faq/utf_bom.html[^].

About Unicode and C++:
http://www.i18nguy.com/unicode/c-unicode.html[^],
http://msdn.microsoft.com/en-us/library/1by39td3%28v=vs.110%29.aspx[^].

Unicode with MFC: http://msdn.microsoft.com/en-us/library/wsdfs47e%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 9-Apr-13 20:07pm    
5'ed! L"Unicode text using escape codes"
Sergey Alexandrovich Kryukov 9-Apr-13 20:36pm    
Thank you, Espen.
Frankly, at this moment of time its hard for me to understand what escape codes did you mean, but I'm very glad to hear from you.
—SA
Espen Harlinn 10-Apr-13 4:14am    
OP may have trouble entering the Persian text in his editor and may have to use escape sequences to get the text he wants.

The escape \xhhh consists of the backslash followed by x followed by one or more hexadecimal digits that are taken to specify the value of the desired character. There is no limit to the number of digits in a hexadecimal sequence. A sequence of octal or hexadecimal digits is terminated by the first character that is not an octal digit or a hexadecimal digit, respectively
Sergey Alexandrovich Kryukov 10-Apr-13 9:46am    
Oh yes, but it's not advisable to enter hard-coded text in the code, even if this is a part of UI. There are resources for that purpose...
—SA
Espen Harlinn 10-Apr-13 9:48am    
Perhaps we should mention that he needs to use a font that supports the required characters too?
Hi.

Add this two simple functions and use its.

void MakeUnicodeString(CStringW &cstrW, const char* multibyte)
{
int nbytes = MultiByteToWideChar(CP_ACP,0,multibyte,-1,0,0);
WCHAR *wstr = new WCHAR[nbytes+2];
MultiByteToWideChar(CP_ACP,0,multibyte,-1,wstr,nbytes);
wstr[nbytes]=0;
cstrW = wstr;
delete [] wstr;
}

void MakeAnsiString(CString &cstr, const WCHAR* wide)
{
int nbytes = WideCharToMultiByte(CP_ACP,0,wide,-1,0,0,0,0);
char *str = new char[nbytes+2];
WideCharToMultiByte(CP_ACP,0,wide,-1,str,nbytes,0,0);
str[nbytes]=0;
cstr = str;
delete [] str;
}

Write me for any questions in google++ or blog:
http://strongcpp.blogspot.ru/[^]
 
Share this answer
 

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