Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to Display TLabel Captions with Symbols


This question is answered.


Permlink Replies: 3 - Last Post: Mar 23, 2018 1:41 PM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Earl Staley

Posts: 99
Registered: 4/9/07
How to Display TLabel Captions with Symbols  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 23, 2018 6:07 AM
I am trying to display a TLabel with a Caption that shows pronunciation. Typically, pronunciations have a lot of weird symbols in them. I am trying to get the symbols to display correctly. I thought UnicodeStrings would do the trick, but apparently not. Here is the code:

//from header file
struct musTerms{
	char Term[20];
	char Answer[256];
	wchar_t Pronunciation[50];
};
//definition
	uStr = "ɛsprɛˈsiːvəʊ";
	wcscpy(MusTerms[6].Pronunciation, uStr.w_str());
 
//output
LabelPronunciation->Caption = MusTerms[index].Pronunciation;

LabelPronunciation->Caption looks like this when I run the program: "?spr??si?v??".

How do I make LabelPronunciation->Caption look like this when the program is run: "ɛsprɛˈsiːvəʊ"?

Earl Staley

Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: How to Display TLabel Captions with Symbols
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 23, 2018 12:14 PM   in response to: Earl Staley in response to: Earl Staley
On 3/23/2018 9:07 AM, Earl Staley wrote:
I am trying to display a TLabel with a Caption that shows pronunciation. Typically, pronunciations have a lot of weird symbols in them. I am trying to get the symbols to display correctly. I thought UnicodeStrings would do the trick, but apparently not. Here is the code:

//from header file
struct musTerms{
	char Term[20];
	char Answer[256];
	wchar_t Pronunciation[50];
};
//definition
	uStr = "ɛsprɛˈsiːvəʊ";
	wcscpy(MusTerms[6].Pronunciation, uStr.w_str());
 
//output
LabelPronunciation->Caption = MusTerms[index].Pronunciation;

LabelPronunciation->Caption looks like this when I run the program: "?spr??si?v??".

How do I make LabelPronunciation->Caption look like this when the program is run: "ɛsprɛˈsiːvəʊ"?

Earl Staley


Try adding the L before hte string to indicate it is a UniCode string. This
worked for me.

struct musTerms{
	char Term[20];
	char Answer[256];
	wchar_t Pronunciation[50];
};
 
//---------------------------------------------------------------------------
void __fastcall TForm6::btn1Click(TObject *Sender)
{
   String uStr = L"ɛsprɛˈsiːvəʊ";
   musTerms musTerms;
   wcscpy(musTerms.Pronunciation, uStr.w_str());
 
   lbl1->Caption = musTerms.Pronunciation;
}

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Earl Staley

Posts: 99
Registered: 4/9/07
Re: How to Display TLabel Captions with Symbols  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 23, 2018 12:51 PM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff,

Thanks for the help. It worked for me as well.

Unicode and me are not on speaking terms right now. Since Unicode doesn't budge, I am grudgingly trying to learn it little-by-little.

Regards...
Earl Staley
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to Display TLabel Captions with Symbols  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 23, 2018 1:41 PM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:

Try adding the L before hte string to indicate it is a UniCode
string.

When assigning a literal to a System::String or System::Char, you
should use the RTL's _D() macro to ensure the character encoding
matches what the RTL natively uses (in case Embarcadero ever decides to
change the character encoding again in the future, since it has already
been changed once before, in CB2009 from ANSI to UTF-16. Whose to say
they don't decide to use UTF-8 in the future, for instance):

String uStr = _D("ɛsprɛˈsiːvəʊ");


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02