UTF8 String

UTF8 String

Post by Suki » Thu, 07 Dec 2006 16:26:09


Hi,
I'm trying to display an UTF8 string in motif using OpenMotif.2.3.0.
More precisely i'm trying to display a copyright symbol using Uncode
symbol 00A9. I'm not able to display the string. I'm getting a white
line in place of the string. What is going wrong?

Here is my sample code.
Any Help is greatly Appreciated.
Thanks,
Surya

#include <Xm/Label.h>
#include <Xm/LabelG.h>
#include <Xm/IconButton.h>
#include <Xm/Form.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/DataF.h>
#include <Xm/PushB.h>
int main(int argc, char *argv[])
{
XtAppContext appContext;
Widget toplevel, form, label, text;
Widget button ;
XmString s1,s2;
XmRendition rendition;
XmRenderTable rtable;
Arg args[14];
Cardinal n;

String fallback[] =
{
"*label1.renderTable: one",
"*label2.renderTable: two",
"*label3.renderTable: three",

"*one.fontType: FONT_IS_XFT",
"*one.renditionForeground: #FF00FF",
"*one.fontName: Trebuchet MS",
"*one.fontSize: 20",

"*two.fontType: FONT_IS_XFT",
"*two.fontName: Trebuchet MS",
"*two.renditionForeground: #FF0000",
"*two.fontSize: 20",

"*three.fontType: FONT_IS_XFT",
"*three.fontName: SUSE Sans Mono",
"*three.renditionForeground: #FFFF00",
"*three.fontSize: 80",

NULL
};

XtSetLanguageProc(NULL, NULL, NULL);
toplevel = XtVaAppInitialize(&appContext, "app",
NULL, 0, &argc, argv, fallback,
XmNtitle, "Anti Alias Font",
NULL);
form = XtVaCreateWidget("form", xmFormWidgetClass, toplevel,
XtVaTypedArg, XmNbackground, XmRString, "#aaaaaa", 8,
NULL);
XtManageChild(form);

char copyright[] = "\u00a9" ;
label = XtVaCreateManagedWidget("label1",
xmLabelWidgetClass, form,
XmNlabelString,
s1=XmStringCreate(copyright, XmCHARSET_TEXT),
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 10,
XmNtopOffset, 10,
NULL);
XmStringFree(copyright);

char string2[] = "Some Text" ;
label = XtVaCreateManagedWidget("label2",
xmLabelGadgetClass, form,
XmNlabelString,
s1=XmStringCreateSimple(string2),
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, label,
NULL);
XmStringFree(s1);

char string3[] = "Some More Text";
label = XtVaCreateManagedWidget("label3",
xmLabelGadgetClass, form,
XmNlabelString,
s1=XmStringCreateSimple(string3),
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, label,
NULL);
XmStringFree(s1);

XtRealizeWidget(toplevel);
XtAppMainLoop(appContext);
return 0;
}
 
 
 

UTF8 String

Post by Chris Sore » Tue, 12 Dec 2006 10:01:55


Change this:


To this:

s1=XmStringCreateLocalized(copyright),

 
 
 

UTF8 String

Post by Suki » Tue, 12 Dec 2006 11:48:03

Hello Chris,
Thanks for your post. But I've found out that it has got nothing to do
with my code. I was using gcc-3.3.3 and it was not working. Now i
changed the compiler to gcc-4.1.1 and its working. The problem lies in
the compiler.

Surya
 
 
 

UTF8 String

Post by Chris Sore » Tue, 12 Dec 2006 14:16:15


Interesting, I've got it working here with gcc-3.4.6...