Other [SOLVED] Lack of knowledge: getting the string encoding

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,

I am asking for a little help about how to get the default string encoding or a link about. The need is to distinguish which is ASCII and which is UTF-8.

Is the best solution to convert the string to ASCII, reencode it and compare it with the original ? That's what I did but sometimes I don't get the real string's length.

This is to be able to know its length in Bytes (about like the problem for the SMS length).

Any help really appreciated. Many thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is no simple way to get the string encoding. The same raw bytes can be valid strings in many different encodings.

If you are only interested in ASCII vs. UTF8 then you can test whether all the bytes are between 0 to 127. In that case you can safely treat it as ASCII string.
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello Erel,
Thanks a lot for the idea. It will solve my need for sure. Great :)
 
Upvote 0
Top