How to get number of symbol in Unicode table?

Hi, i'm beginner from russia(sorry for bad english). How can i get number of symbol in Unicode table? For example: method receiveing string contains: "???", and returns string: "042D044E042F". To avoid large switch operator i want to do it automatically. Is it possible? P.S. I'll be gratefull for any idea!

Google?

I'm googled it approximately 7 hours. Found 2 libraries and one example of code. 1st lib did not compiled, second did not give correct data, and example of code too did not give correct data((( Help me, please...

042D 044E 042F

04 is the character set I guess so you can ignore that, that leaves 2D, 4E and 2F. What exactly do you want to do with them, execute different code according the the character received?


Rob

The only options I can see are to hard-code the mapping for the characters you want to support, or call some external service to perform the mapping. How to do that would depend how your input string is encoded. Is it some form of ascii, UTF, what?

ekopiy:
"???"

Graynomad:
042D 044E 042F

04 is the character set I guess so you can ignore that, that leaves 2D, 4E and 2F. What exactly do you want to do with them, execute different code according the the character received?


Rob

I want to perform message in PDU format(character set UCS2, it’s repeating UTF-8). I need to convert every char of string to Unicode number and concatenate them so as to send to siemens c35 via UART.

PeterH:
The only options I can see are to hard-code the mapping for the characters you want to support, or call some external service to perform the mapping. How to do that would depend how your input string is encoded. Is it some form of ascii, UTF, what?

ekopiy:
“???”

I need universal methot to convert any char to unicode number. See my answer to previous user to understand what i need. P.S. It was hard to translate your message, and maybe i didn’t quiet understand youe post, sorry))

I found solution:

void setup() {
  Serial.begin(19200);
  wchar_t st = L'?';
  Serial.println(st, HEX);
}

void loop() {
  // put your main code here, to run repeatedly:   
}

This code printing "427"(Unicode number) if i converting variable to HEX format, and printing "1063"(html code) without of conversion. So, my problem is solved. Thanks tho all who responsed!!!

Sorry for offtop, but how to up reputation of users, who answered me? I can't find any button((

Hit the "karma" + sign under their names. Click on mine as much as you like :slight_smile:


Rob

ekopiy:
I found solution:

I'm not sure that solves the problem you described.

What that's doing is printing out the numeric value (the code point) of the character literal in your program source. Unless your sketch is written in unicode those aren't unicode code points, although depending what encoding you're using they may happen to coincide with the corresponding unicode code points in some cases.

You didn't say where your characters are coming from or how they are encoded. You need to know how they're encoded in order to answer the question properly.

Hmmm... Seems i mistaked...
I'll try to decribe my problem more detailed:
I need method, which could send my string to Serial1 port(i have mega2560).
This code is working only for "const wchar_t"

  wchar_t st = L'?';
  Serial.println(st, HEX);

But i need something like this:

void setup() {
  Serial1.begin(19200);
  text2Pdu("??????");
}

void loop() {
  // put your main code here, to run repeatedly:   
}

void text2Pdu(Strint inpStr) {  // I think type can be char*
  //here characters of my string converting to numbers in unicode
  Serial1.println();// Sending converted string to serial port.
}

I need only russian characters, but i think that it is not important. So, I still have not solved this problem, if there are any ideas, please post them!) I tried to use mbstowcs(), swprintf(), but they are not declared((

In all your examples, the strings you're dealing with are all hard-coded in your sketch. Are those the only ones you need to deal with?

PeterH:
In all your examples, the strings you’re dealing with are all hard-coded in your sketch. Are those the only ones you need to deal with?

I did not realized reading from sd card yet, but i’ll have to read string from *.txt file and to convert it to Unicode numbers. I seems that coding of *.txt file doesn’t important. Am i right?