The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Insert Unicode and formatting into graph string
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

michaelbraun

USA
21 Posts

Posted - 07/13/2015 :  6:22:42 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2015 sr2
Operating System:Windows

Hi, I have created a graph layer and added a text graph object to the layer. I would like this text to include formatting (ie subscript) and a couple unicode characters. I currently have the following:

                        GraphObject gresults = gl.CreateGraphObject(GROT_TEXT,"Results");
                        //setup results string to be displayed
			string slstr, xcstr, cstr;
			//convert doubles to strings and set decimal places to be displayed
			slstr = ftoa(t,"*3");
			xcstr = ftoa(xc,"*6");
			cstr = ftoa(c,"*5");
			string strresults = "t = " + slstr + " Å\n2q_c = " + xcstr + "°\nc = " + cstr + " Å";
			gresults.Text = strresults;


where in the string strresults, I would like the t to be a capital greek L (unicode 004C), the q to be a theta (unicode 03B8), and the _c to be a subscript c. For the unicode I tried entering the string as "\\x(004C)" but this just gives me a regular "L".

SeanMao

China
288 Posts

Posted - 07/14/2015 :  03:11:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The syntax to insert a unicode is shown in this example:


void test_unicode()
{
	GraphLayer gl = Project.ActiveLayer();
	GraphObject go = gl.GraphObjects("Text");
	go.Text = "\\g(\\(x004C))"; // Insert greek L
}


Regards!

Sean

OriginLab Tech Service
Go to Top of Page

michaelbraun

USA
21 Posts

Posted - 07/14/2015 :  10:29:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Worked great! Here is the code I ended up using for the text box if anyone is searching for this in the future:

                        gl = Project.ActiveLayer();
			GraphObject gresults = gl.CreateGraphObject(GROT_TEXT,"Results");
			
			//setup results string to be displayed
			string slstr, xcstr, cstr;
			//convert doubles to strings and set decimal places to be displayed
			slstr = ftoa(t,"*3");
			xcstr = ftoa(xc,"*6");
			cstr = ftoa(c,"*5");
			string strresults = "\\g(\\(x004c)) = " + slstr + " Å\n2\(x03B8)\-(c) = " + xcstr + "°\nc = " + cstr + " Å";
			gresults.Text = strresults;
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000