Jump to content

Convert ASCII String into UTF-16 string


Annatooli

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

 

Link to comment
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
}

 

Link to comment
Share on other sites

  • MVP 2023

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.  

Link to comment
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.

×
×
  • Create New...