Jump to content
Sign in to follow this  
Annatooli

Convert ASCII String into UTF-16 string

Recommended Posts

Is there way to convert STRING-ASCII to STRING-UTF16. 

I have data table with UTF-16 column for messages, but in one case I want to add number there, but number is in ASCII. Maybe someone knows some existing method for this kind of conversion ?

I can probably create this function, but is UniLogic internally "Little endian" or "Big endian" ?

Anatoly

 

Share this post


Link to post
Share on other sites

It was actually easier than I imagined:

static void String_AToU(volatile char* FI, int FILen, volatile short* FO, int FOLen)
{
	// User code starts below this comment
		for (int i=0 ; i < FILen ; i++ ){
			FO[i] = (short) FI[i];
		}
		FOLen = FILen;	

	// User code ends above this comment
}

 

Share this post


Link to post
Share on other sites

When first looked at this post I couldn't spell "UTF-16".  I knew it was a valid string type but never thought more about it.  This post woke up the squirrel and I leaned on my friend Dr. Google to at least learn what this data type is.  So now I know more than I did this morning about how many different characters can be referenced with this format (1,112,064).

I sit at your feet, Anatoly.  What are you doing that you need this?

Joe T.  

Share this post


Link to post
Share on other sites

On screen I have long data table where is written states like open, closed, waiting etc.  But most of my messages are in Russian, so only way  for this is UTF-16. 

In one  instance  I need to show timer value there and this is where conversion is needed.

Anatoly

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...