[英]Convert an ASCII string into its decimal equivilent - java/android
I'm trying to build an application that receives UDP string messages and then converts the string of characters in the packet to their decimal equivilents, i've tried a few methods and done some research but I cant seem to make any progress on this, i'm sure there must be a smart and easy way of doing this. 我正在尝试构建一个接收UDP字符串消息,然后将数据包中的字符串转换为十进制等效项的应用程序,我尝试了几种方法并进行了一些研究,但是我似乎无法在此方面取得任何进展,我敢肯定必须有一个聪明而简单的方法来做到这一点。 Could anyone help me on this at all?
有人可以帮我吗? thanks
谢谢
char ch = 'A';
int code = ch;
Now you have the decimal equivalent in code
. 现在您在
code
具有十进制等效项。
If you have a String
you should do this for each char
from the String
. 如果您有
String
,则应该对String
每个char
执行此操作。
You can get the decimal equivalent of ascii like this, 您可以像这样获得十进制的ascii,
int i='a';
System.out.println("i:="+i);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.