How to display chinese charactor with IStatic? | developer.brewmp.com How to display chinese charactor with IStatic? | developer.brewmp.com

Developer

How to display chinese charactor with IStatic?

Forums:

My program is as following:

WSTRCPY(psz,(AECHAR *)L"chinese charactors");
ISTATIC_SetText(pIStatic,..,psz,..)

It works on Emulator,
but it display nothing on handset(KZ-820).

Why?

ÎÒÓÃÄãÌṩµÄ·½Ê½ÊÔÁËһϣ¬µ±°Ñ×Ö·û´®ÌîÔÚAECHAR * pTitle,ÉÏʱ¿ÉÒÔÏÔʾ£¬µ«ÊÇÌîÔÚpTextÖв»ÄÜÏÔʾ¡£ISTATIC_SetText(pIStatic, psz,psz,AEE_FONT_NORMAL,AEE_FONT_NORMAL);
ÕâÑù¿ÉÒÔÕýÈ·ÏÔʾ±êÌ⣬µ«ÊÇÎı¾ÄÚÈÝÊÇÂÒÂ룬ºóÃæÌîNULL¾Í¸É´à¶¼²»ÏÔʾÁË£¬ÕâÊÇΪʲô£¿

ÎÒÓÃÄãÌṩµÄ·½Ê½ÊÔÁËһϣ¬µ±°Ñ×Ö·û´®ÌîÔÚAECHAR * pTitle,ÉÏʱ¿ÉÒÔÏÔʾ£¬µ«ÊÇÌîÔÚpTextÖв»ÄÜÏÔʾ¡£ISTATIC_SetText(pIStatic, psz,psz,AEE_FONT_NORMAL,AEE_FONT_NORMAL);
ÕâÑù¿ÉÒÔÕýÈ·ÏÔʾ±êÌ⣬µ«ÊÇÎı¾ÄÚÈÝÊÇÂÒÂ룬ºóÃæÌîNULL¾Í¸É´à¶¼²»ÏÔʾÁË£¬ÕâÊÇΪʲô£¿

are your chinese character numerical values between 0x4E00 and 0x9FA5 ?

are your chinese character numerical values between 0x4E00 and 0x9FA5 ?

you realize too that L macro will not work on arm.

you realize too that L macro will not work on arm.

I use the L macro all the time, works fine with the ADS 1.1 ARM compiler.

I use the L macro all the time, works fine with the ADS 1.1 ARM compiler.

Quote:Originally posted by mrfun
I use the L macro all the time, works fine with the ADS 1.1 ARM compiler.
Hmm, from what I've read and observed, there is no wchar_t /wide char string literal support in ADS 1.1.
I see it working with string literals in which the characters are ASCII, but I don't see it working for characters that are above ASCII.

Quote:Originally posted by mrfun
I use the L macro all the time, works fine with the ADS 1.1 ARM compiler.
Hmm, from what I've read and observed, there is no wchar_t /wide char string literal support in ADS 1.1.
I see it working with string literals in which the characters are ASCII, but I don't see it working for characters that are above ASCII.

The following syntax works in VC++ but not in ADS1.2:
L"SomeStr"
To make ADS happy, the above has to be changed to:
(AECHAR*)L"SomeStr"
According to Harbison and Steele in "C: A Reference Manual" (4E), "A string constant prefixed by the letter L is of type array of wchar_t" (p.33).
wchar_t is not implemented as a proper type in the ARM compiler, but merely a typedef name for unsigned short. It's funny that the L syntax is even tolerated by the ARM compiler, in the second code snippet above. I wonder if it does anything at all?
Murray

The following syntax works in VC++ but not in ADS1.2:
L"SomeStr"
To make ADS happy, the above has to be changed to:
(AECHAR*)L"SomeStr"
According to Harbison and Steele in "C: A Reference Manual" (4E), "A string constant prefixed by the letter L is of type array of wchar_t" (p.33).
wchar_t is not implemented as a proper type in the ARM compiler, but merely a typedef name for unsigned short. It's funny that the L syntax is even tolerated by the ARM compiler, in the second code snippet above. I wonder if it does anything at all?
Murray

Interesting. I've never used the (AECHAR*) cast with L"" and have not had any compiling problems. I'm using a fully patched up 1.2 ADS compiler btw, not 1.1, my bad.
WSPRINTF(pApp->szBuf, (MAX_STRING_LENGTH * sizeof(AECHAR)), L"Scroll Type: %d",pApp->GetFrameSkip());
is a line of code taken from a finished game that is available for purchase.
I've only used it with standard ASCII characters though.

Interesting. I've never used the (AECHAR*) cast with L"" and have not had any compiling problems. I'm using a fully patched up 1.2 ADS compiler btw, not 1.1, my bad.
WSPRINTF(pApp->szBuf, (MAX_STRING_LENGTH * sizeof(AECHAR)), L"Scroll Type: %d",pApp->GetFrameSkip());
is a line of code taken from a finished game that is available for purchase.
I've only used it with standard ASCII characters though.

My ADS 1.2 is at build 842, right up to date, I think.
When I first started working with it, I needed the cast to make it work, or at least get rid of a warning (trying to remember, that was 2 or 3 patches before build 842). Have you got any warnings disabled?
Maybe I can ditch the cast now. I'll try it tomorrow.

My ADS 1.2 is at build 842, right up to date, I think.
When I first started working with it, I needed the cast to make it work, or at least get rid of a warning (trying to remember, that was 2 or 3 patches before build 842). Have you got any warnings disabled?
Maybe I can ditch the cast now. I'll try it tomorrow.

Quote:Originally posted by Murray Bonner
The following syntax works in VC++ but not in ADS1.2:
L"SomeStr"
To make ADS happy, the above has to be changed to:
(AECHAR*)L"SomeStr"
According to Harbison and Steele in "C: A Reference Manual" (4E), "A string constant prefixed by the letter L is of type array of wchar_t" (p.33).
wchar_t is not implemented as a proper type in the ARM compiler, but merely a typedef name for unsigned short. It's funny that the L syntax is even tolerated by the ARM compiler, in the second code snippet above. I wonder if it does anything at all?
Murray
Yes, thats how I overcame the compiler complaints, by casting to (AECHAR*)...and if "SomeStr" is all ASCII, it will be rendered properly. It's when "SomeStr" contains chars above 0x7F that things don't work properly. The characters just don't get rendered...at least thats what happens on the vx6000 I've been testing.
I havent taken the time to find out exactly what happens on the ARM. I just threw the wide char string literals I needed into the res file.

Quote:Originally posted by Murray Bonner
The following syntax works in VC++ but not in ADS1.2:
L"SomeStr"
To make ADS happy, the above has to be changed to:
(AECHAR*)L"SomeStr"
According to Harbison and Steele in "C: A Reference Manual" (4E), "A string constant prefixed by the letter L is of type array of wchar_t" (p.33).
wchar_t is not implemented as a proper type in the ARM compiler, but merely a typedef name for unsigned short. It's funny that the L syntax is even tolerated by the ARM compiler, in the second code snippet above. I wonder if it does anything at all?
Murray
Yes, thats how I overcame the compiler complaints, by casting to (AECHAR*)...and if "SomeStr" is all ASCII, it will be rendered properly. It's when "SomeStr" contains chars above 0x7F that things don't work properly. The characters just don't get rendered...at least thats what happens on the vx6000 I've been testing.
I havent taken the time to find out exactly what happens on the ARM. I just threw the wide char string literals I needed into the res file.