//字符转ASCII码: public static int Asc(string character) { if (character.Length == 1) { System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding(); int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0]; return (intAsciiCode); } else
public class DigitalTrans { /** * 数字字符串转ASCII码字符串 * * @param String * 字符串 * @return ASCII字符串 */ public static String StringToAsciiString(String content) { String result = ""; int max = content.length(); for (int i = 0; i < max; i++) { char c
public class CharToAscii { public static void main(String[] args) { CharToAscii.AscToString(); CharToAscii.StringToAsc(); char a = '0'; int b = 22307; //char类型参与四则运算的时候是转化成asciii码的, 字符‘0’的ascii码为48,要转换成int型,只需要(‘0’-48)即可 System.out.println(a-48); Sys
有时候会需要用到字符的ASCII码,一时之间调试时可能会忘记字符与ASCII码对应的数字. 最近喜欢用浏览器控制台直接跑JS代码,将这个代码直接贴到浏览器控制台,即可调试(谷歌浏览器快捷键 ctrl+shift+j) function GetAsciiCode(){ var str = prompt("请输入几个字符","");//接收字符串 var strAscii = new Array();//用于接收ASCII码 for(var i = 0 ; i <