|
See also here [^].
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
|
|
|
|
|
yeah.that says a == &a is true.
but why the out put will 5?
maybe in &a+1,it treat the array as one variable,so &a+1 will jump the entire array to the end of the array? if right,all the thing become easy,i will understand too.
Thanks
|
|
|
|
|
kcynic wrote: but why the out put will 5?
because of pointer arimethic: sizeof(a)== 5 * sizeof(int) , hence &a+1 == ((int*)&a)+5 .
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
|
|
|
|
|
I see it now.Thanks very much.
|
|
|
|
|
kcynic wrote: int a[] = {1,2,3,4,5};
int* ptr = (int*)(&a+1);
kcynic wrote: So,&a should be a point of a,its type should be int**.
no, &a is of type int (*)[5], not int **. Othercase is Don't think int ** and int [][], multi dimensional array are same the former stores pointer to some different location while later stores in values in contigious location.
kcynic wrote: But,why ptr-1 point the last element of the array?
so, &a is of type int (*)[5], (not int **), so incrementing a pointer increments based on the type, so (&a + 1) actually points next to the enter size of array; since that is the type, int (*) [5].
so ptr - 1 points to last element.
i repeat int (*)[5] is not same as int **, you can ensure this by trying the following code,
int *ptr = (int *)(((int **)&a) + 1);
|
|
|
|
|
|
Hi,
At present i was assigned a work of preparing an application that to support multilingual interface.
It is expected to support many languages esp, chinese, japanese etc.
It would be helpful anyone guide me...
Thanks in advance,
Ganesh
Thanks a lot
|
|
|
|
|
Is your application Unicode aware at first? Don't ask me what Unicode is.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have some idea about unicode...can you give me any samples or links that help me to know better.
Thanks in advance.
Thanks a lot
|
|
|
|
|
You still haven't answered my question. Is your application Unicode aware?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi
Thanks for ur response!
No, in Project settings C/C++ Tab-> Project options -> it was set "_MBCS" , therefore i guess it is not aware of unicode.
Please guide me!
Thanks a lot
Thanks a lot
|
|
|
|
|
So, you guessed it right. Replace _MBCS with _UNICODE. Do that, and try compiling. You'll hit a dead end and then start reading on Generic text mappings. But, fortunately for you, if the project already is following Generic text mappings, then you could easily proceed by installing the language scripts that you plan to use, and then get on with your project. I say, you have a long way to go. But go step by step and it isn't very difficult.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
This statement doesn't give you too much hope
"I have some idea about unicode..." holy cow, it's time to leave the room.
|
|
|
|
|
But usually I give them a try. Some people just pick it up right off. And if they don't, I do leave the room.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have some idea about unicode...can you give me any samples or links that help me to know better.
Thanks in advance.
Thanks a lot
|
|
|
|
|
What OS versions are you targetting? WinCE (3.x, 4.x, 5.x, 6.x), Win9X, Win NT/2000/XP/Vista, Server 2K, Server 2003, Server 2008.
This will probably the biggest determining factor in how you go about this job.
What features do you want in multi-languages, fixed text display, variable text display generated from numeric values or network messages, variable text display generated from user input in a single fixed language, variable text display generated from user input directly in variable languages requiring IME (Input Method Editor) support.
You want Chinese and Japanese support and presumably English but do you want Arabic or Hebrew RTL (Right To Left) laguage support.
Do you need to support SIPs (Software Input Panels) or merely different keyboard layouts?
Each of these levels of requirements will likely change the way you need to do things, which technologies you need to incorporate and how hard the task is.
Are you starting the project from scratch of upgrading an existing single language code base?
Do you use any 3rd party components, especially in the UI and can they support the languages you want?
Last but not least get some good books on Internationalization (I18n) and add www.unicode.org to you browser favourites. Good Luck.
P.S. if this is a substantial application running on multiple Os version then clear a year in your schedule.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Target OS: Win XP,
It is expected to deal with variable text display, and to support arabic also, i need SIP. Already i am in the middle of the project and i need to add these features, perhaps i may be needed to create controls from scratch.
Please help me how to proceed.
Thanks
Thanks a lot
|
|
|
|
|
NO U Need not Create all the interfaces once again.
U Just need to Give id to all the Controls and load them using
Resource Dll.
<br />
<br />
inline HINSTANCE LoadResourceDll()<br />
{<br />
<br />
HKEY hkey;<br />
unsigned long no = 2048;<br />
DWORD pos;<br />
BYTE strRegValue[2048] = "\0";<br />
CString csLanguage = _T("");<br />
CString csDllPath;<br />
wchar_t *pwcDllPath = NULL;<br />
HINSTANCE m_hResInstance = NULL;<br />
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("Path to ur registered application"),0,_T("Registration"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hkey,&pos) == ERROR_SUCCESS)<br />
{<br />
if( RegQueryValueEx(hkey,_T("CurrentLanguage"),NULL,NULL,strRegValue,&no) == ERROR_SUCCESS) <br />
{ <br />
csLanguage = (wchar_t*)strRegValue ;<br />
csLanguage.TrimLeft();<br />
csLanguage.TrimRight();<br />
}<br />
<br />
}<br />
TCHAR lpBuffer[1028];<br />
GetSystemDirectory(lpBuffer,1028);<br />
csDllPath = (LPCTSTR) (const char*) lpBuffer;<br />
csDllPath.TrimLeft();<br />
csDllPath.TrimRight();<br />
if (Encrypt(_T("ENG")) == csLanguage)<br />
csDllPath+= "\\DUresENG.dll";<br />
else if (Encrypt(_T("JPN")) == csLanguage)<br />
csDllPath+= "\\DUresJPN.dll";<br />
else<br />
csDllPath+= "\\DUresENG.dll";<br />
<br />
m_hResInstance = LoadLibrary(csDllPath);<br />
<br />
<br />
return m_hResInstance;<br />
}
And In ur .Cpp
Call Controls like this, Call all controls in one Function. call them in OnInitDialog of Ur Dialog Class.
void CAttributeProperties::SetDialogLabels()
{
m_csLabel = LoadResourceString(m_hResInstance ,AfxGetApp()->m_hInstance,1);<br />
GetDlgItem(IDOK)->SetWindowText(m_csLabel);
}
And call them in OnInitDialog of Ur Dialog Class.
BOOL CAttributeProperties::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
<br />
SetDialogLabels();<br />
}
|
|
|
|
|
OK XP is a good start that makes it a lot easier than it might be.
You need to research UNICODE of course, the link I gave you is a start.
SIPS are not hard to write but there aren't many samples about, look for some Open Source ones. You may have to trawl incomprehensible Chinese and Japanese web sites and guess at the link for downloading to get what you need.
Two other technologies you should look into IMEs, you'll need to get and use 3 of these, for Chinese, Japanese and Korean for development and you may or may not choose to ship them. I think there are some fairly standard ones with XP and some more popular after market replacements, quiz your far east sales people to find out what your potential customers are used to. Install these, switch on support of the language in control panel and hey presto your standard Edit control becomes IME aware and capable of entering complex characters like Japanese Katakana ?? ( way cool you have to try it )
The other tech to look at is TSF (Text Services Framework) it's huge and I've never used it (not available on CE) but it might take a lot of work out of what you need to do.
Look also at multilanguage resources for string tables, I'm sure there's something on CP about doing that effectively.
When it comes to rendering text, even RTL, XP will do that for you reasonably well, DrawTextEx backend onto a whole DLL full of UNICODE goodies, BIDI (Bidirectional text) algorithum, Script Shaping for Arabic and of course all the glyph mapping stuff. Be glad you don't have to roll your own as some of this stuff is seriously hard .
Two rules to always keep in mind.
1. Never use any hard coded text in your code that might end up anywhere near the UI. Keep it all in resources or better still in external files e.g. XML
2. Keep a definitive list of the client system requirements for using your software, e.g. 'must have Japanese language pack installed', 'must have working Korean IME'
otherwise it's likely to end up working on your dev PC but nowhere else.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks a lot.
Before getting into deep i want to create a simple application that displays a chinese text in a Static control?
How can i achieve that ? Sorry if i am troubling you.
Thanks a lot again!
Thanks a lot
|
|
|
|
|
That's a good place to start. You need a few things.
WinXP Chinese Language pack installed. It's probably still an optional Windows Update on the Windows Update site.
Make sure your application has the UNICODE and _UNICODE (someone at MS screwed up) preprocessor symbols defined in the project.
The Static control must be using a font with Chinese characters, e.g. Arial UNICODE
Copy some Chinese characters from a Web page and paste them into your Chinese language string table resource. The BBC news site news.bbc.co.uk is good 'cause they have multiple translations of the main pages you can access.
Make sure your code uses tcs or wcs versions of all the string handling functions, TCHAR or wchar_t everywhere and never char so you don't corrupt the UNICODE characters between loading them from your resource and calling SetWindowText on your Static control.
That it. ??
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I tried to copy the chinese string into the string table but it is simply being printed as ???,??. I changed the language of the string table. What could be the steps i need to follow to achieve that ?
And also here are the snippets i have done, just look at this and guide me if i am wrong.
TCHAR * p = _T("MLST ????");
CStatic * pStatic = new CStatic;
CRect rcDefault(10,10,10,20);
pStatic->Create(_T(""),WS_TABSTOP|WS_CHILD|WS_VISIBLE,rcDefault,this,3000);
pStatic->ModifyStyleEx (0,WS_EX_CLIENTEDGE);
pStatic->ModifyStyle(0,WS_GROUP);
pStatic->MoveWindow (0,0,100,30);
pStatic->Invalidate ();
pStatic->UpdateWindow();
CFont* pFont;
pFont = new CFont();
pFont->CreateFont( 20,0,0,0,FW_NORMAL,TRUE,FALSE,0,DEFAULT_CHARSET ,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS, _T("Arial Unicode MS"));
pStatic->SetFont(pFont);
pStatic->SetWindowText(p);
Thanks a lot
Thanks a lot
modified on Saturday, March 29, 2008 8:44 AM
|
|
|
|
|
If text is appearing as question marks or boxes then the program displaying it isn't coping too well with UNICODE itself, either the font it's using or it isn't fully UNICODE enabled. The Character Map Accessory program that comes with Windows is very useful for looking at what is and is not in a given font and getting the correct U+ values for the letters you want. Try getting a single character from there if C&P from IE is not working. You have made sure you've got all the relevant language packs installed haven't you?
Your code looks OK. I would probably have done it the easy way with a Dialog template but that's just because I'm lazy.
For more on multilanguage Resource files you'll need to search Code Project, it's too long since I did any of that to give you advice, we use external XML files to lookup translations and resource files are all in English holding the source strings for looking up in the XML.
Whatever you do don't despair, 2 years ago I was doing exactly what you're doing trying to get just any Chinese output anyhow on a Dialog under XP. Now I have a large WinCE project in 17 languages with multi-IME text entry (Microsoft say you can't do this on CE ). Good Luck
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thank you very much for your valuable response! i will do as per your directions.!
Thanks a lot
|
|
|
|
|
Did u able to paste Chinese string in Static control ?
|
|
|
|
|