Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

How to get unicode(?) from SQL Server to NX?

Have an app I'm trying to write for NX, to fill in the title block based on data stored in a SQL Server 2012 database.

Everything was working great until I encountered a string that needs to be mixed "ASCII" letters and Chinese characters.  My welcome to Internationalization :-)

 

Getting data from the database

	char temp_str[10][2000];
	WCHAR wtemp_str[2000];
	int i ;
...
	for (i = 0; i < 3; i++)
	{
		// what I was using for all
		temp_str[i][0] = '\0';
		SQLGetData(hstmt, (i+4), SQL_C_CHAR, &(temp_str[i]), sizeof(temp_str[i]), &cbData);
	}
	// added this in
	SQLGetData(hstmt, (i+4), SQL_C_WCHAR, wtemp_str, sizeof(wtemp_str), &cbData);

// other strings are passed in std::string strings
// the wtemp_str is copied into a std::wstring

So when I need to set the data in the cell, or write to the info window, How do I convert the data?

 

Should I leave it as a WCHAR array? (doesn't seem to compile)

Do I need the UNICODE compile directive?

Can I directly set an NXString, like "NXString sTemp = wtemp_str"

 

Ken "Oh no, I've been I18Ned" Akerboom

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


5 REPLIES

Re: How to get unicode(?) from SQL Server to NX?

Looks like you can pass a second parameter to NXString constructor called NXStringMode.  May be that will help.

 

Re: How to get unicode(?) from SQL Server to NX?

[ Edited ]

 

See attached - when I tried to paste it in initially, it was pretty scrambled.  This is from the NX10 What's New docs.

 

Re: How to get unicode(?) from SQL Server to NX?

I (sort of) have things working.

I'm able to output the stuff to the info window reliably (Chinese chaacters show up as Chinese characters).

NX is a bit more challenging....

I have 2 parts.  In one, the Chinese characters show fine.

In the other, they are "square boxes"

Before I create a small test program to submit to GTAC, anyone have any idea where to look / what to do in the "bad" part to fix this?

Note that the text does NOT have the "<Fn>...<F>" legacy stuff to switch fonts, but it does work fine in the one part.

Ken

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Solution
Solution
Accepted by topic author Ken_A
‎02-12-2016 01:27 PM

Re: How to get unicode(?) from SQL Server to NX?

Do both parts use the same font? If not, does the font in the "bad" part support all the unicode characters?

Re: How to get unicode(?) from SQL Server to NX?

That was it.

"Bad" part was "Arial"

"Good" part was "Arial Unicode MS"

 

Switch the font & "voila" - Chinese characters!

 

Thanks!

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled