Any way to use u8 literal with a varible?
const char* name[32];
(u8)name//something like this
I need to convert name to utf-8 and i just don't know how.
Any way to use u8 literal with a varible?
const char* name[32];
(u8)name//something like this
I need to convert name to utf-8 and i just don't know how.
No, you can't use u8
with a variable. It only applies to string literals at compile-time, not to data at runtime.
You say in comments that you are reading data from other processes. You have to know the exact encoding of that data before you can convert it to anything meaningful. Is it already in UTF-8? Or is it in KOI8-R? ISO-8859-5? Don't guess!
You could try performing known hueristics on the data to try to detect the encoding dynamically (and there are 3rd party libraries available for that purpose), but that is still a form of guessing (albeit somewhat educated guessing) and thus subject to potentially misleading results.
If you can't find out the encoding, then you can't safely convert it to UTF-8 (or anything else, for that matter).